Ant 命令

在 Windows 中将 ant_path/bin 设置到系统变量 path 中去之後, 就可以使用 ant 命令了. 这个命令有不少参数.

ant -help 可以打印所有的参数:

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

-projecthelp

只显示设置了 description 属性的 target 信息, 不设置的不显示, 另外有两个 Ant 的编译参数可以显示: -verbose, -debug

示例:

C:\eclipse-jee-galileo-win32\workspace\argouml-i18n-zh>ant -projecthelp
Buildfile: build.xml
Main targets:
clean          Clean out all built files.
install        Copy the ${result.jar} file to the ArgoUML directory.
jar            Build the ${result.jar} file.
patch_and_run  --> patch to main project and run
patch_zh       patch zh properties to main project
run            Run with this module.
update_en_src  move english to local, be the reference
Default target: run