<?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="hello_jar" value="hello1.jar" />
<!-- 定义初始化操作 , 新建一个文件夹为 classes -->
<target name="init">
<mkdir dir="${dest}" />
</target>
<!-- 定义编译操作
1.根据包的层次创建文件夹,
2.编译*.java 文件为*.class文件;
depends init method
-->
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${dest}" />
</target>
<!-- 定义构建jar 包操作, depends compile method -->
<target name="build" depends="compile" >
<jar jarfile="${hello_jar}" basedir="${dest}" />
</target>
<!-- 运行构建操作 -->
<target name="run" depends="build">
<java classname="test.ant.HelloWorld" classpath="${hello_jar}" />
</target>
<!-- 清除构建操作
1.清除文件夹
2.清除*.jar文件
-->
<target name="clean">
<delete dir="${dest}"/>
<delete file="${hello_jar}"/>
</target>
<!-- 重新构建操作
1.清除以前创建的文件
2.重新执行构建操作
-->
<target name="rerun" depends="clean,run">
<ant target="clean" />
<ant target="run" />
</target>
</project>
Ant templet
最新推荐文章于 2018-04-13 00:08:02 发布