ant打jar包的xml示例

<project name="wztTest" default="dist" basedir=".">

<description>

simpleexamplebuildfile

</description>

<!--setglobalpropertiesforthisbuild-->

<propertyname="src"location="src"/>

<propertyname="build"location="build"/>

<propertyname="bin"location="bin"/>

  <property name="dist"  location="dist"/>

 <!-- 引用用到的jar -->

<pathid="classpath">

<filesetdir="lib">

<includename="*.jar"/>

</fileset>

    </path>

 

<targetname="init">

<!--Createthebuilddirectorystructureusedbycompile-->

    <mkdir dir="${build}"/>

  </target>

  <target name="compile" depends="init" description="compile the source " >

<!--这里拷贝bin目录下所有文件,目的是将除class之外的文件都拷贝(因为打jar包时ant只会拷贝class文件),如xml文件,properties文件等-->

<copytodir="${build}">

<filesetdir="${bin}">

</fileset>

</copy>

<!--Compilethejavacodefrom${src}into${build}-->

<javacsrcdir="${src}"destdir="${build}">

<classpathrefid="classpath"/>

</javac>

  </target>

  <target name="dist" depends="compile"        description="generate the distribution" >

    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->

<jarjarfile="wztTest.jar"basedir="${build}"/>

  </target>

 

<target name="clean" description="clean up" >

<!--Deletethe${build}and${dist}directorytrees-->

<deletedir="${build}"/>

 </target>

</project>

相关推荐