JAVA下ant的配置

来源:互联网 发布:麟龙四色谱指标源码 编辑:程序博客网 时间:2024/05/20 13:07
 下载http://www.apache.org/dist/ant/binarie或http://ant.apache.org/bindownload.cgi下的apache-ant-1.7.1-bin.zip 
接压安装。 

ant的配置: 
1。解压ant的包到本地目录。 
2。在环境变量中设置ANT_HOME,值设为你的安装目录。 
3。在环境变量中设置JAVA_HOME,值设为你的jdk安装目录。 
4。把ANT_HOME/bin加到你系统的path目录中去。

SET ANT_HOME=D:/jakarta-ant-1.7.1 //注意是Ant的安装目录,不是bin子目录 
SET PATH=%PATH%;%ANT_HOME%/bin;


在cmd模式下输入 ant -version回车,看到输出说明配置成功。
运行Ant非常简单,(当你正确地安装Ant后)只要输入ant就可以了。

ex:>ant -version
Apache Ant version 1.7.1 compiled on June 27 2008

n 没有指定任何参数时,Ant会在当前目录下查询build.xml文件。如果找到了就用该文件作为buildfile。如果你用 -find 选项。Ant就会在上级目录中寻找buildfile,直至到达文件系统的根。要想让Ant使用其他的buildfile,可以用参数 -buildfile file,这里file指定了你想使用的buildfile。

n 可以指定执行一个或多个target。当省略target时,Ant使用标签<project>的default属性所指定的target。
命令行选项总结:
ant [options] [target [target2 [target3] ...]]
Options:
-help print this message
-projecthelp print project help information
-version print the version information and exit
-quiet be extra quiet
-verbose be extra verbose
-debug print debugging information
-emacs produce logging information without adornments
-logfile file use given file for log output
-logger classname the class that is to perform logging
-listener classname add an instance of class as a project listener
-buildfile file use specified buildfile
-find file search for buildfile towards the root of the filesystem and use the first one found
-Dproperty=value set property to value 
例子
ant
使用当前目录下的build.xml运行Ant,执行缺省的target。
ant -buildfile test.xml
使用当前目录下的test.xml运行Ant,执行缺省的target。
ant -buildfile test.xml dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target。
ant -buildfile test.xml -Dbuild=build/classes dist
使用当前目录下的test.xml运行Ant,执行一个叫做dist的target,并设定build属性的值为build/classes。

原创粉丝点击