这是apache-ant-1.9.4-bin.zip下载,Ant是一个Apache基金会下的跨平台(tái)的构件(jiàn)工具,它可以实现项目的自动构(gòu)建和部(bù)署等功能(néng)。
apache-ant-1.9.4-bin.zip专业(yè)的JAVA软件开(kāi)发工具,集编(biān)译、测试、部署等步(bù)骤联系在(zài)一起的自(zì)动化(huà)工具,并附有(yǒu)apache ant环境变量配(pèi)置,它(tā)具(jù)有很(hěn)强的快平台(tái)操(cāo)作(zuò)性。搭建QT for androids 开发环境时(shí)需要设置JDK,androids SDK、NDK以及apache-ant-1.9.6-bin,才(cái)能保(bǎo)证开(kāi)发环境(jìng)的正常运作。
1、使用java开发(fā),并用xml存储build信息,因(yīn)此是(shì)跨平台的;
2、程序(xù)员可以自己扩展Ant。程序员可以自(zì)己写(xiě)java程序来扩展Ant,创建自己的tasks。
一、解(jiě)压ant安(ān)装包在D:\SWE下
二、环境(jìng)变量配置
ANT_HOME D:\SWE\apache-ant-1.8.4
CLASSPATH ;%ANT_HOME%lib;
PATH ;%ANT_HOME%bin;
三、测试是否安装成功
在cmd命令方(fāng)式下输入:ant -version
Ant安装与配置(zhì)" title="Apache Ant安装与配置" action-data="http%3A%2F%2Fs3.sinaimg.cn%2Fmiddle%2F62ef85c24c4d9d4834dd2%26690" action-type="show-slide" style="margin: 0px; padding: 0px; border: 0px; list-style: none;" 1)Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib
命令行敲ant命令(lìng)后提(tí)示:“Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib”;ANT_HOME环境变量已经配置;
解决途径:将“C:\Program Files\Java\jdk1.6.0_16\lib”目录下(xià)的tools.jar文件拷贝到“C:\Program Files\Java\jre6\lib”目录下,重(chóng)新运行(háng)命令ant,运行正(zhèng)常,问(wèn)题解(jiě)决。
2)在cmd命令中:输入ant,如(rú)果输(shū)出: Buildfile:build.xml does not exist!
Build failed
说明ant安装成功。
四、运行第(dì)一个ant脚本
在(zài)D:\ant_home\apache-ant-1.8.1\bin\下面新建目录(lù)build,再(zài)在该目录下新建目录src
同时在src目录下新(xīn)建HelloWorld.java
内(nèi)容如(rú)下:
package test.ant;
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
};
编写(xiě)build.xml文件(jiàn)保(bǎo)存(cún)到D:\ant_home\apache-ant-1.8.1\bin\
内(nèi)容如下:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="HelloWorld" default="run" basedir=".">
<property name="src" value="build/src" />
<property name="dest" value="build/classes" />
<property name="hello_jar" value="hello.jar" />
<property name="name" value="HelloWorld" />
<property name="version" value="1.0" />
<property name="year" value="2010" />
<echo message="----------- ${name} ${version} [${year}] ------------" />
<target name="init">
<echo message="mkdir ${dest}"></echo>
<mkdir dir="${dest}" />
</target>
<target name="compile" depends="init" description="Compile Java code">
<javac srcdir="${src}" destdir="${dest}" includeantruntime="on"/>
</target>
<target name="build" depends="compile">
<jar jarfile="build/${hello_jar}" basedir="${dest}"/>
</target>
<target name="run" depends="build">
<java classname="test.ant.HelloWorld" classpath="build/${hello_jar}"/>
</target>
<target name="clean">
<delete dir="${dest}" />
<delete file="${hello_jar}" />
</target>
</project>
运行:
Buildfile: D:\ant_home\apache-ant-1.8.1\bin\build.xml
[echo] ----------- HelloWorld 1.0 [2010] ------------
init:
[echo] mkdir build/classes
compile:
[javac] Compiling 1 source file to D:\ant_home\apache-ant-1.8.1\bin\build\classes
build:
[jar] Building jar: D:\ant_home\apache-ant-1.8.1\bin\build\hello.jar
run:
[java] Hello World
BUILD SUCCESSFUL
Total time: 1 second
检查(chá)在目录D:\ant_home\apache-ant-1.8.1\bin\build下生成hello.jar
