ant是一个基于java的编译工具
1.下载ant(我下载的是1.9.3版本)
http://ant.apache.org/bindownload.cgi
2.解压文件(我用的是win7系统,下载的zip文件,直接解压)
3.配置环境(默认已经安装jdk以及配置好jdk环境)
ANT_HOME=E:apache-ant-1.9.3(注意自己的目录)
将%ANT_HOME%in加入到path环境里面
4.测试
当不带参数运行ant时将会在当前目录下找一个build.xml的文件
为了测试是否正确安装我创建了一个文件E:apache-ant-1.9.3samplesuild.xml
<!-- simple ant build script to test an ant installation -->
<project name="testinstall" default="run" basedir=".">
<target name="init">
<available file="asimplehelloobject.java" property="asimplehelloobject" />
</target>
<target name="asimplehelloobject" unless="asimplehelloobject" depends="init">
<echo file="asimplehelloobject.java">
public class asimplehelloobject
{
public static void main(String[] args) {
System.out.println("asimplehelloobject.main was called");
}
}
</echo>
<echo message="wrote asimplehelloobject.java" />
</target>
<target name="compile" depends="asimplehelloobject">
<javac destdir="." srcdir="." debug="on" classpath="." includeantruntime="on">
<include name="asimplehelloobject.java"/>
</javac>
</target>
<target name="run" depends="compile">
<java classname="asimplehelloobject" classpath="." />
<echo message="ant appears to be successfully installed" />
</target>
</project>
跳转到samples目录中执行ant命令
结果:
Buildfile: E:apache-ant-1.9.3samplesuild.xml
init:
asimplehelloobject:
[echo] wrote asimplehelloobject.java
compile:
[javac] Compiling 1 source file to E:apache-ant-1.9.3samples
run:
[java] asimplehelloobject.main was called
[echo] ant appears to be successfully installed
BUILD SUCCESSFUL Total time: 1 second
结果表示已经安装ant成功了。