需要設置的環境變量
ANT_HOME
JAVA_HOME
PATH
假定ant解壓在c
則在命令行下執行以下命令
set ANT_HOME=c:\ant
set JAVA_HOME=D:\j
set PATH=%PATH%;c:\ant\bin
一個ant 工程目錄結構
C
\src
\build\classes
\lib
\jar
\build
建立工程描述文件build
<?xml version=
<project default=
<echo message=
<property file=
<target name=
<echo message=
<delete dir=
<mkdir dir=
</target>
<target name=
<echo message=
<javac srcdir=
</target>
<target name=
<echo message=
<java classname=
<classpath>
<pathelement path=
</classpath>
</java>
</target>
</project>
建立工程資源文件
文件內容是下面一行內容
classpath=build\\classes
package hello
public class HelloAnt {
public static void main(String[] args) {
System
}
}
C:\workspace\ant
Buildfile: build
[echo] pulling in property files
init:
[echo] init
[delete] Deleting directory C:\workspace\ant
[mkdir] Created dir: C:\workspace\ant
compile:
[echo] compile the java source files
[javac] Compiling
main:
[echo] calling java to run this java project
[java] hello ant
BUILD SUCCESSFUL
Total time:
C:\workspace\ant
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28515.html