1、下载地址:
2、安装:
1、window以下:
解压apache-ant-1.8.4-bin.zip 到某个文件夹 F:\tools\apache-ant
环境变量加入 ANT_HOME F:\tools\apache-ant
path 追加 F:\tools\apache-ant\bin
測试:ant
C:\Documents and Settings\zhangchao02>ant
Buildfile: build.xml does not exist! Build failed測试成功
2、linux以下:
解压 cd /usr/local/src tar -zxvf apache-ant-1.8.4-bin.tar.gz
环境变量 /etc/profile 加入 export ANT_HOME=/usr/local/src/apache-ant-1.8.4
path 追加 /usr/local/src/apache-ant-1.8.4/bin
source /etc/profile
測试 ant -version
Apache Ant(TM) version 1.8.4 compiled on May 22 2012
3、ant 具体说明
1、參考地址:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="TestDemo"> <target name="A" if="ant.java.version"> <echo message="Java Version: ${ant.java.version}" /> <delete dir="build" /> </target> <target name="main" depends="A" unless="amigo"> <description> test depends </description> <echo message="first ant xml ${basedir}" /> <mkdir dir="build"/> <mkdir dir="build/class"/> <javac srcdir="src" destdir="build/class" /> </target> <target name="run" depends="main"> <java classname="HelloGame"> <classpath> <pathelement path="build/class"/> </classpath> </java> </target> <target name="jar" depends="run"> <jar destfile="helloGame.jar" basedir="build/class"> <manifest> <attribute name="Main-class" value="HelloGame" /> </manifest> </jar> </target> </project>