ant build.xml compile 编译 指定 jar

<?xml version="1.0" encoding="UTF-8" ?>
<project name="HelloWorld" default="run" basedir=".">
<property name="src" value="src"/>
<property name="dest" value="classes"/>
<property name="jar_name" value="helloWorld.jar"/>
<property name="lib.dir" value="lib" />
<target name="init">
   <mkdir dir="${dest}"/>
</target>
<path id="classpath">
	<fileset file="${lib.dir}/*.jar" />
</path>
<target name="compile" depends="init">
   <javac srcdir="${src}" destdir="${dest}">
        <!-- 这里指定依赖的lib库路径 -->
   	<classpath refid="classpath" />
   </javac>
</target>
<target name="build" depends="compile">
   <jar jarfile="${jar_name}" basedir="${dest}"/>
</target>
<target name="run" depends="build">
   <java classname="test.ant.HelloWorld" classpath="${hello_jar}"/>
</target>
<target name="clean">
   <delete dir="${dest}" />
   <delete file="${hello_jar}" />
</target>
<target name="rerun" depends="clean,run">
   <ant target="clean" />
   <ant target="run" />
</target>
</project>

 

你可能感兴趣的:(ant,build.xml,classpath,指定类路径)