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.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>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>
  42. option gives a list of this project's
  43. targets. First those with a description, then those without one.</p>
  44. <p>Command-line option summary:</p>
  45. <pre>ant [options] [target [target2 [target3] ...]]
  46. Options:
  47. -help print this message
  48. -projecthelp print project help information
  49. -version print the version information and exit
  50. -quiet be extra quiet
  51. -verbose be extra verbose
  52. -debug print debugging information
  53. -emacs produce logging information without adornments
  54. -logfile <i>file</i> use given file for log output
  55. -logger <i>classname</i> the class that is to perform logging
  56. -listener <i>classname</i> add an instance of class as a project listener
  57. -buildfile <i>file</i> use specified buildfile
  58. -find <i>file</i> search for buildfile towards the root of the filesystem and use the first one found
  59. -D<i>property</i>=<i>value</i> set <i>property</i> to <i>value</i>
  60. </pre>
  61. <h3>Examples</h3>
  62. <blockquote>
  63. <pre>ant</pre>
  64. </blockquote>
  65. <p>runs Ant using the <code>build.xml</code> file in the current directory, on
  66. the default target.</p>
  67. <blockquote>
  68. <pre>ant -buildfile test.xml</pre>
  69. </blockquote>
  70. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  71. the default target.</p>
  72. <blockquote>
  73. <pre>ant -buildfile test.xml dist</pre>
  74. </blockquote>
  75. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  76. target called <code>dist</code>.</p>
  77. <blockquote>
  78. <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
  79. </blockquote>
  80. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  81. target called <code>dist</code>, setting the <code>build</code> property to the
  82. value <code>build/classes</code>.</p>
  83. <h3>Files</h3>
  84. <p>The Ant wrapper script for Unix will source (read and evaluate) the
  85. file <code>~/.antrc</code> before it does anything - the Windows batch
  86. file invokes <code>%HOME%\antrc_pre.bat</code> at the start and
  87. <code>%HOME%\antrc_post.bat</code> at the end. You can use these
  88. files to set/unset environment variables that should only be visible
  89. during the execution of Ant. See the next section for example.</p>
  90. <h3>Environment Variables</h3>
  91. <p>The wrapper scripts use the following environment variables (if
  92. set):</p>
  93. <ul>
  94. <li><code>JAVACMD</code> full path of the Java executable. Use this
  95. to invoke a different JVM than <code>JAVA_HOME/bin/java(.exe)</code>.</li>
  96. <li><code>ANT_OPTS</code> command line arguments that should be
  97. passed to the JVM - for example, you can define properties or set
  98. the maximum Java heap size here.</li>
  99. </ul>
  100. <h2>Running Ant by Hand</h2>
  101. <p>If you have installed Ant in the do-it-yourself way, Ant can be started
  102. with:</p>
  103. <blockquote>
  104. <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
  105. </blockquote>
  106. <p>These instructions actually do exactly the same as the <code>ant</code>
  107. command. The options and target are the same as when running Ant with the <code>ant</code>
  108. command. This example assumes you have set your classpath to include:</p>
  109. <ul>
  110. <li><code>ant.jar</code></li>
  111. <li>jars/classes for your XML parser</li>
  112. <li>the JDK's required jar/zip files</li>
  113. </ul>
  114. <br>
  115. <hr>
  116. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  117. Reserved.</p>
  118. </body>
  119. </html>