ant 常用命令

首先安装ANT
假定Ant安装在c:\ant\目录下。下面是设定环境的命令:
set ANT_HOME=c:\ant
set JAVA_HOME=c:\j2sdk1.4.1
set PATH=%PATH%;%ANT_HOME%\bin

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

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

你也可以设定一些属性,以覆盖buildfile中指定的属性值(参看property task)。可以用 -Dproperty=value 选项,这里property是指属性的名称,而value则是指属性的值。也可以用这种办法来指定一些环境变量的值。你也可以用property task来存取环境变量。只要将 -DMYVAR=%MYVAR% (Windows) 或 -DMYVAR=$MYVAR (Unix) 传递给Ant -你就可以在你的buildfile中用${MYVAR}来存取这些环境变量。

还有两个选项-quite,告诉Ant运行时只输出少量的必要信息,如:BUILD SUCCESSFUL。而-verbose,告诉Ant运行时要输出更详细的信息。

可以指定执行一个或多个target。当省略target时,Ant使用标签 <project> 的default属性所指定的target。
-projecthelp选项输出项目的描述信息和项目target的列表。先列出那些有描述的,然后是没有描述的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 which 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
-D <property> = <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。

Ant的buildfile是用XML写的。每个buildfile都含有一个project。
常用的元素有 "project "、 "target "、 "path "、 "property "等。
常用的任务有 "ant "、 "mkdir "、 "delete "、 "copy "、 "javac "、 "jar "、 "javadoc "、 "echo "等

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值