运行 ANT

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

没有指定任何参数时,Ant会在当前目录下查询build.xml文件。

如果找到了就用该文件作为buildfile。

如果你用 -find 选项,Ant就会在上级目录中寻找buildfile,直至到达文件系统的根目录。

要想让Ant使用其他的buildfile,可以用参数 -buildfile file,这里file指定了你想使用的buildfile。

可以指定执行一个或多个target。

当省略target时,Ant使用标签的default属性所指定的target。

命令行选项总结:ant [options] [target [target2 [target3] ...]] Options: -help, -h print this message -projecthelp, -p print project help information -version print the version information and exit -diagnostics print information that might be helpful to diagnose or report problems. -quiet, -q be extra quiet -verbose, -v be extra verbose -debug, -d print debugging information -emacs, -e produce logging information without adornments -lib <path> specifies a path to search for jars and classes -logfile <file> use given file for log -l <file> '' -logger <classname> the class which is to perform logging -listener <classname> add an instance of class as a project listener -noinput do not allow interactive input -buildfile <file> use given buildfile -file <file> '' -f <file> '' -D<property>=<value> use value for given property -keep-going, -k execute all targets that do not depend on failed target(s) -propertyfile <name> load all properties from file with -D properties taking precedence -inputhandler <class> the class which will handle input requests -find <file> (s)earch for buildfile towards the root of -s <file> the filesystem and use it -nice number A niceness value for the main thread: 1 (lowest) to 10 (highest); 5 is the default -nouserlib Run ant without using the jar files from ${user.home}/.ant/lib -noclasspath Run ant without using CLASSPATH -autoproxy Java1.5+: use the OS proxy settings -main <class> override Ant's normal entry point例如: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。