Eclipse中集成和调试Ant工程

新的eclipse中已经安装了ant,如果没有去官网下载安装即可。

Ant是什么? 
Ant是一种基于Java和XML的build工具。

2 下载、安装Ant 

1,安装apache-ant-1.7.0的前提需要安装JDK
2,将apache-ant-1.7.0的安装包解压到E:\tool-ant\目录下,当然tool-ant是我另外新建的文件夹,路径变为E:\tool-ant\apache-ant-1.7.0
3, 环境变量的设置
   3.1 找到系统路径path,与前面的变量值用分号隔开,E:\tool-ant\apache-ant-1.7.0\bin
   3.2 新建一个ANT_HOME变量,变量值为E:\tool-ant\apache-ant-1.7.0
4 运行E:\tool-ant\apache-ant-1.7.0\bin目录下的antMS-DOS批处理文件


验证ant是否安装成功可运行cmd输入ANT -version


安装Ant
下载.zip文件,解压缩到c:\ant1.3(后面引用为%ANT_HOME%)

2.1 在你运行Ant之前需要做一些配置工作。
? 将bin目录加入PATH环境变量。 
? 设定ANT_HOME环境变量,指向你安装Ant的目录。在一些OS上,Ant的脚本可以猜测ANT_HOME(Unix和Windos NT/2000)-但最好不要依赖这一特性。 
? 可选地,设定JAVA_HOME环境变量(参考下面的高级小节),该变量应该指向你安装JDK的目录。
注意:不要将Ant的ant.jar文件放到JDK/JRE的lib/ext目录下。Ant是个应用程序,而lib/ext目录是为JDK扩展使用的(如JCE,JSSE扩展)。而且通过扩展装入的类会有安全方面的限制。
2.2 运行Ant

运行Ant非常简单,当你正确地安装Ant后,只要输入ant就可以了。

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。

原文地址:https://www.cnblogs.com/youxin/p/2781679.html