Apache Ant学习笔记(2):Apache Ant命令行

  Apache Ant的命令行是Apache Ant构建的基础。虽然我们通常在IDE中集成Apache Ant并使用它进行构建,但是了解Apache Ant的命令行对我们在IDE中使用Apache Ant还是很有好处的,如对IDE中Apache Ant的默认设置进行修改以符合自己的要求。此外,还是有用到命令行的场景,虽然很少。

  进入命令行,输入ant -help,显示如下(括弧中的文字是选项的注释):

ant [options] [target [target2 [target3] ...]]


Options:


  -help, -h                     print this message(输出Apache Ant的ant命令的帮助信息)


  -projecthelp, -p           print project help information(输出工程相关的帮助信息)


  -version                      print the version information and exit(输出Apache Ant的版本信息)


  -diagnostics                print information that might be helpful to diagnose or report problems.(输出Apache Ant项目的运行环境、依赖库等信息,为错误诊断和报告提供一些有用的帮助信息)


  -quiet, -q                    be extra quiet(隐藏Apache Ant执行时的提示输出信息。命令行将不会输出具体target的执行信息)


  -silent, -S                   print nothing but task outputs and build failures(只输出任务的输出和构建失败信息)


  -verbose, -v                be extra verbose(输出Apache Ant执行的详细信息,包括操作系统、java环境等信息)


  -debug, -d                  print debugging information(输出Apache Ant执行调试时的信息、详细的log信息)


  -emacs, -e                  produce logging information without adornments(生成无修饰的日志信息)


  -lib <path>                 specifies a path to search for jars and classes(指定搜索jar和类的路径,让Apache Ant可以使用这些类文件)


  -logfile <file>               use given file for log(使用指定的文件作为Apache Ant的日志输出文件,而不是在命令行输出)


    -l     <file>                 ''(与-logfile <file>用法相同)


  -logger <classname>       the class which is to perform logging(指定Apache Ant使用的日志输出类)


  -listener <classname>      add an instance of class as a project listener(指定一个项目的监听器)


  -noinput                      do not allow interactive input(不允许交互输入)


  -buildfile <file>             use given buildfile(使用当前目录下的指定的构建文件进行构建操作,并执行默认的target。)


    -file    <file>                  ''(与-buildfile <file>用法相同)


    -f       <file>                  ''(与-buildfile <file>用法相同)


  -D<property>=<value>      use value for given property(设定一个Apache Ant使用的属性值对,这些属性值对可以在target中直接引用,效果与buildfile中的<property/>相同,可以覆盖已设定的属性值)


  -keep-going, -k              execute all targets that do not depend on failed target(s)(执行所有的不依赖于失败的target的target)


  -propertyfile <name>        load all properties from file with -D properties taking precedence(加载指定文件中的所有属性,这些属性将被优先使用,相对于构建文件中的使用<property/>设置的属性)


  -inputhandler <class>       the class which will handle input requests(指定处理输入请求的的类)


  -find <file>                 (s)earch for buildfile towards the root of the filesystem and use it(向根目录方向查找指定的构建文件并进行构建。默认首先在当前目录下查找指定的构建文件,如果没有找到,则往上一级目录查找,直到根目录为止。在这个过程中如果找到了指定的构建文件,则进行构建操作,否则输出错误提示。)


    -s  <file>                 ''(与-find <file>用法相同)


  -nice  number               A niceness value for the main thread:1 (lowest) to 10 (highest); 5 is the default(指定main线程的优先级:1到10,1最低,10最高,5为默认值)


  -nouserlib                    Run ant without using the jar files from ${user.home}/.ant/lib(运行Apache Ant的时候不使用来自${user.home}/.ant/lib的jar文件)


  -noclasspath                Run ant without using CLASSPATH(运行Apache Ant的时候不使用CLASSPATH指定的类)


  -autoproxy                  Java1.5+: use the OS proxy settings(使用OS的代理设置,需要java1.5及以上的环境)


  -main <class>              override Ant's normal entry point(使用指定的类替代Apache Ant的通常的入口点)

 

posted @ 2014-08-31 16:56  hwzs  阅读(453)  评论(0编辑  收藏  举报