<project name="lis"default="dist" basedir="."><!-- 項目名,default的值是對應下面默認執行的target(任務) --><description>simple example build file</description><!-- set global properties forthis build --><property name="project" location="lis"/><property name="src" location="${project}/java/src"/><!-- 設置變量,指向要編譯的java代碼的位置 --><property name="lib.dir" location="${project}/ui/WEB-INF/lib"/><!-- 設置變量,指向所依賴的jar包所在的位置 --><property name="build" location="${project}/build"/><!-- 設置變量,指向編譯后的class文件的位置 --><property name="dist" location="${project}/dist"/><!-- 設置變量,指向編譯后生成jar包的位置 --><!-- 設置要依賴的jar包規則 --><path id="project.class.path"><pathelement path="${build}"/><fileset dir="${lib.dir}"><include name="**/*.jar"/></fileset></path><target name="init"><!-- Create the time stamp --><tstamp/><!-- Create the build directory structure used by compile --><mkdir dir="${build}"/></target><target name="compile" depends="init"description="compile the source "><!-- Compile the java code from ${src} into ${build}--><javac encoding="GBK" srcdir="${src}" destdir="${build}" includeantruntime="on" classpath="${lib}"><classpath refid="project.class.path"/><!-- 引入依賴的jar包 --></javac></target><target name="dist" depends="compile"description="generate the distribution"><!-- Create the distribution directory --><mkdir dir="${dist}/lib"/><!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --><jar jarfile="${dist}/lib/lis-${DSTAMP}.jar" basedir="${build}"/><!-- 配置生成的jar包的路徑 --></target><target name="clean"description="clean up"><!-- Delete the ${build} and ${dist} directory trees --><delete dir="${build}"/><delete dir="${dist}"/></target></project>