ant 依赖jar包
<project default="run" basedir=".">
<property name="lib.dir" location="lib" />
<property name="src" location="src" />
<property name="classpath" location="build" />
<property name="dist" location="dist" />
<property name="webserver_jar" value="webserver.jar" />
<!--定义项目编译的时候,以来的lib包的路径-->
<path id="project.class.path">
<pathelement path="${classpath}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<mkdir dir="${src}" />
<mkdir dir="${classpath}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${dist}" />
<copy file="${webserver_jar}" todir="${lib.dir}" />
<copy file="JettySample.java" todir="${src}" />
<copy file="${webserver_jar}" todir="${dist}" />
</target>
<target name="compile" depends="init">
<!--target="1.4" 表示编译器用1.4的方式编译,当然也可以采用1.5,classpath 中的refid这表示依赖于那些jar包编译-->
<javac fork="true" target="1.4" srcdir="src" destdir="${classpath}" debug="true" >
<classpath refid="project.class.path" />
</javac>
</target>
<target name="jar" depends="compile">
<jar destfile="${dist}/${webserver_jar}" update="true" basedir="${classpath}">
<!--定义jar包运行的时候,实现要寻找的含有main方法的主类-->
<manifest>
<attribute name="Main-class" value="JettySample" />
</manifest>
</jar>
</target>
<target name="run" depends="jar,clean">
<java jar="${dist}/${webserver_jar}" fork="true" />
</target>
<target name="clean">
<delete dir="${classpath}"/>
<delete dir="${src}"/>
<delete dir="${lib.dir}"/>
</target>
</project>