You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

running.html 5.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h1>Running Ant</h1>
  8. <p>Running Ant is simple, when you installed it as described in the previous
  9. section. Just type <code>ant</code>.</p>
  10. <p>When nothing is specified, Ant looks for a <code>build.xml</code>
  11. file in the current directory. If found, it uses that file as the
  12. buildfile. If you use the <code>-find</code> option,
  13. Ant will search for a buildfile in
  14. the parent directory, and so on, until the root of the filesystem
  15. has been reached. To make Ant use
  16. another buildfile, use the command-line
  17. option <code>-buildfile <i>file</i></code>,
  18. where <i>file</i> is the buildfile you want to use.</p>
  19. <p>You can also set properties that override properties specified in the
  20. buildfile (see the <a href="CoreTasks/property.html">property</a> task).
  21. This can be done with
  22. the <nobr><code>-D<i>property</i>=<i>value</i></code></nobr> option,
  23. where <i>property</i> is the name of the property,
  24. and <i>value</i> is the value for that property.
  25. This can also be used to pass in the value of some environment variables.
  26. You can also access environment variables using the <a href="CoreTasks/property.html">
  27. property</a> task.
  28. Just pass <nobr><code>-DMYVAR=%MYVAR%</code></nobr> (Windows) or
  29. <nobr><code>-DMYVAR=$MYVAR</code></nobr> (Unix)
  30. to Ant - you can then access
  31. these variables inside your buildfile as <code>${MYVAR}</code>.</p>
  32. <p>Two more options are: <nobr><code>-quiet</code></nobr>,
  33. which instructs Ant to print less
  34. information on the console when running, and
  35. <nobr><code>-verbose</code></nobr>, which causes Ant to print
  36. additional information to the console.</p>
  37. <p>It is also possible to specify one or more targets that should be executed.
  38. When omitted, the target that is specified in the
  39. <code>default</code> attribute of the <code>&lt;project&gt;</code> tag is
  40. used.</p>
  41. <p>The <nobr><code>-projecthelp</code></nobr> option prints out the
  42. description of the project, if it exists, followed by a list of this
  43. project's targets. First those with a description, then those without
  44. one.</p>
  45. <p>Command-line option summary:</p>
  46. <pre>ant [options] [target [target2 [target3] ...]]
  47. Options:
  48. -help print this message
  49. -projecthelp print project help information
  50. -version print the version information and exit
  51. -quiet be extra quiet
  52. -verbose be extra verbose
  53. -debug print debugging information
  54. -emacs produce logging information without adornments
  55. -logfile <i>file</i> use given file for log output
  56. -logger <i>classname</i> the class that is to perform logging
  57. -listener <i>classname</i> add an instance of class as a project listener
  58. -buildfile <i>file</i> use specified buildfile
  59. -find <i>file</i> search for buildfile towards the root of the filesystem and use the first one found
  60. -D<i>property</i>=<i>value</i> set <i>property</i> to <i>value</i>
  61. </pre>
  62. <h3>Examples</h3>
  63. <blockquote>
  64. <pre>ant</pre>
  65. </blockquote>
  66. <p>runs Ant using the <code>build.xml</code> file in the current directory, on
  67. the default target.</p>
  68. <blockquote>
  69. <pre>ant -buildfile test.xml</pre>
  70. </blockquote>
  71. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  72. the default target.</p>
  73. <blockquote>
  74. <pre>ant -buildfile test.xml dist</pre>
  75. </blockquote>
  76. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  77. target called <code>dist</code>.</p>
  78. <blockquote>
  79. <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
  80. </blockquote>
  81. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  82. target called <code>dist</code>, setting the <code>build</code> property to the
  83. value <code>build/classes</code>.</p>
  84. <h3>Files</h3>
  85. <p>The Ant wrapper script for Unix will source (read and evaluate) the
  86. file <code>~/.antrc</code> before it does anything - the Windows batch
  87. file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
  88. <code>%HOME%\antrc_post.bat</code> at the end. You can use these
  89. files to set/unset environment variables that should only be visible
  90. during the execution of Ant. See the next section for example.</p>
  91. <h3>Environment Variables</h3>
  92. <p>The wrapper scripts use the following environment variables (if
  93. set):</p>
  94. <ul>
  95. <li><code>JAVACMD</code> - full path of the Java executable. Use this
  96. to invoke a different JVM than <code>JAVA_HOME/bin/java(.exe)</code>.</li>
  97. <li><code>ANT_OPTS</code> - command-line arguments that should be
  98. passed to the JVM. For example, you can define properties or set
  99. the maximum Java heap size here.</li>
  100. <li><code>ANT_ARGS</code> - Ant command-line arguments. For example,
  101. set <code>ANT_ARGS</code> to point to a different logger and to
  102. include the <code>-find</code> flag.</li>
  103. </ul>
  104. <h2>Running Ant by Hand</h2>
  105. <p>If you have installed Ant in the do-it-yourself way, Ant can be started
  106. with:</p>
  107. <blockquote>
  108. <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
  109. </blockquote>
  110. <p>These instructions actually do exactly the same as the <code>ant</code>
  111. command. The options and target are the same as when running Ant with the <code>ant</code>
  112. command. This example assumes you have set your classpath to include:</p>
  113. <ul>
  114. <li><code>ant.jar</code></li>
  115. <li>jars/classes for your XML parser</li>
  116. <li>the JDK's required jar/zip files</li>
  117. </ul>
  118. <br>
  119. <hr>
  120. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  121. Reserved.</p>
  122. </body>
  123. </html>