1、build.properties
base =D:\\test
2、build.xml
<?xml version="1.0" encoding="GBK"?> <project name="getYhdProducts" default="jar" basedir="."> <property file="build.properties"/> <property name="java.target.version" value="1.6" /> <property name="jar.name" value="test" /> <property name="pis.build" location="${base}/build" /> <property name="pis.libs" location="${base}/lib/" /> <property name="excludes" value="**/CVS/*,**/.nbattrs,**/.project,**/.classpath" /> <target name="clean" description="Delete existing output directories"> <delete dir="${pis.build}" /> <delete file="${base}/${jar.name}.jar" /> </target> <target name="compile" depends="clean" description="Compile the pis classes"> <mkdir dir="${pis.build}" /> <!-- <uptodate property="classesUpToDate" targetfile="${pis.output.jars}/pis.jar"> <srcfiles dir= "${base}/src" includes="**/*.java" excludes="${build.excludes},${excludes}"/> <srcfiles dir= "${base}/src" includes="**/*.properties,**/*.txt,**/*.xml,**/*.xsd,**/*.dtd,**/*.sql" excludes="${excludes}" /> </uptodate> --> <javac srcdir="${base}/src" destdir="${pis.build}" debug="on" optimize="on" deprecation="on" source="1.6" target="${java.target.version}"> <classpath> <fileset dir="${pis.libs}"> <include name="**/*.jar"/> </fileset> </classpath> <!-- compilerarg value="-Xlint:unchecked"/ --> </javac> <!-- <copy todir="${pis.build}"> <fileset dir="${base}/src" includes="**/*.properties,**/*.xml" excludes="${excludes}"/> <fileset dir="${base}/config" includes="**/*.properties,**/*.xml" excludes="${excludes}"/> </copy> --> </target> <target name="jar" depends="compile" description="Generate the getdata4products.jar files"> <unzip dest="${pis.build}"> <fileset dir="${pis.libs}"> <include name="*.jar"/> </fileset> </unzip> <!-- <delete FILE="${pis.build}/META-INF/MANIFEST.MF" /> <copy todir="${pis.build}/META-INF/"> <fileset file="${base}/metainf/MANIFEST.MF"/> </copy> <zip zipfile="${base}/${jar.name}.jar" > <zipfileset dir="${pis.build}" /> </zip> --> <jar jarfile="${base}/${jar.name}.jar" basedir="${pis.build}" > <manifest> <attribute name="Class-Path" value="."/> <attribute name="Main-class" value="test"/> </manifest> </jar> </target> </project>