General Java application ant Template

Source: Internet
Author: User

Build. ant

<? XML version = "1.0" encoding = "UTF-8"?> <Project default = "output" basedir = ". "> <tstamp> </tstamp> <property file =" build. properties "/> <property file =" version. properties "/> <property environment =" env "/> <property name =" src. dir "value =" $ {basedir}/src "/> <property name =" Lib. dir "value =" $ {basedir} "/> <property name =" build. dir "value =" $ {basedir}/build "/> <property name =" output. dir "value =" $ {basedir}/output "/> <! -- Director --> <target name = "output"> <antcall target = "clean"/> <antcall target = "init"/> <antcall target = "getversion"/> <antcall target = "build"/> <antcall target = "copy"/> <antcall target = "copylib"/> <antcall target = "makejar"/> </Target> <! -- Define classpath --> <path id = "project. classpath"> <fileset file = "$ {Lib. dir}/*. Jar"/> </path> <! -- Initialize the task and clear the directory --> <target name = "clean"> <Delete dir = "$ {build. dir}"/> </Target> <! -- Initialize the task and create the directory --> <target name = "init"> <mkdir dir = "$ {build. dir} "/> <mkdir dir =" $ {output. dir} "/> </Target> <! -- Get version information --> <target name = "getversion"> <propertyfile file = "version. properties "comment =" this is version file "> <Entry key =" builddate "type =" date "value =" now "pattern =" yyyy-mm-dd hh: mm: SS "/> </propertyfile> <property file =" version. properties "/> <copy todir =" $ {build. dir} "> <fileset dir = ". "> <include name =" version. properties "/> </fileset> </copy> </Target> <! -- Compile the Java program --> <target name = "build"> <javac srcdir = "$ {SRC. dir} "destdir =" $ {build. dir} "DEBUG =" on "> <classpath refID =" project. classpath "/> </javac> </Target> <target name =" copy "> <! -- Copy the configuration file of the production environment --> <copy todir = "$ {build. dir} "Overwrite =" true "> <fileset dir =" $ {SRC. dir} "> <include name = "**/*. properties "/> <include name = "**/*. XML "/> </fileset> </copy> </Target> <target name =" copylib "> <mkdir dir =" $ {output. dir}/lib "/> <copy todir =" $ {output. dir}/lib "> <fileset dir =" $ {Lib. dir} "> <include name = "*. jar "/> </fileset> </copy> </Target> <! -- Package the JAR file --> <target name = "makejar"> <jar destfile = "$ {output. dir}/$ {projectname}-$ {dstamp}-$ {version }. jar "basedir =" $ {build. dir} "> <manifest> <attribute name =" Main-class "value =" com. fsti. mytest "/> </manifest> </jar> </Target> </Project>

Build. Properties

# build.propertiesprojectname=testproject

Version. Properties

#This is Version File#Tue Apr 30 18:14:42 CST 2011version=1.0.0buildDate=2011-04-30 18\:14\:42

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.