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