【ANT】java项目生成文件示例

 1 <?xml version="1.0" ?>
 2 <project default="dist">
 3     <property name="srcDir" location="src" />
 4     <property name="buildDir" location="build" />
 5     <property name="distDir" location="dist" />
 6     
 7     <target name="init">
 8         <tstamp/>
 9         <mkdir dir="${buildDir}"/>
10         <mkdir dir="${distDir}"/>
11     </target>
12     
13     <target name="compile" depends="init">
14         <javac srcdir="${srcDir}" destdir="${buildDir}"/>
15     </target>
16     
17     <target name="dist" depends="compile">
18         <jar destfile="${distDir}/package-${DSTAMP}.jar" basedir="${buildDir}">
19             <manifest>
20                 <attribute name="Built-By" value="${user.name}"/>
21                 <attribute name="Main-Class" value="package.Main"/>
22             </manifest>
23         </jar>
24         <jar destfile="${distDir}/package-src-${DSTAMP}.jar" basedir="${srcDir}"/>
25     </target>
26     
27     <target name="clean" depends="dist">
28         <delete dir="${buildDir}"/>
29         <delete dir="${distDir}"/>
30     </target>
31     
32 </project>
build.xml

build.xml所在目录:

 

src目录:

运行ANT后的目录:

运行ANT后生成的build目录及目录内文件:

运行ANT后生成的dist目录及目录内文件:

 

posted @ 2017-03-09 19:59  xiongjiawei  阅读(403)  评论(0编辑  收藏  举报