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.

install.html 15 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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>Installing Ant</h1>
  8. <h2><a name="getting">Getting Ant</a></h2>
  9. <h3>Binary edition</h3>
  10. <p>The latest stable version of Ant can be downloaded from <a
  11. href="http://jakarta.apache.org/builds/ant/release/v1.3/bin/">
  12. http://jakarta.apache.org/builds/ant/release/v1.3/bin/</a>.
  13. If you like living on the edge, you can download the latest version from <a
  14. href="http://jakarta.apache.org/builds/ant/nightly/">http://jakarta.apache.org/builds/ant/nightly/</a>.</p>
  15. <h3>Source Edition</h3>
  16. <p>If you prefer the source edition, you can download the source for the latest Ant release from <a
  17. href="http://jakarta.apache.org/builds/ant/release/v1.3/src/">
  18. http://jakarta.apache.org/builds/ant/release/v1.3/src/</a>.
  19. Again, if you prefer the edge, you can access
  20. the code as it is being developed via CVS. The Jakarta website has details on
  21. <a href="http://jakarta.apache.org/site/cvsindex.html" target="_top">accessing CVS</a>. Please checkout the
  22. jakarta-ant module.
  23. See the section <a href="#buildingant">Building Ant</a> on how to
  24. build Ant from the source code.
  25. You can also access the
  26. <a href="http://jakarta.apache.org/cvsweb/index.cgi/jakarta-ant/" target="_top">
  27. Ant CVS repository</a> on-line. </p>
  28. <hr>
  29. <h2><a name="sysrequirements">System Requirements</a></h2>
  30. <p>
  31. To build and use Ant, you must have a JAXP-compliant XML parser installed and
  32. available on your classpath.</p>
  33. <p>
  34. The binary distribution of Ant includes the reference
  35. implementation of JAXP 1.1. Please see
  36. <a href="http://java.sun.com/xml/" target="_top">http://java.sun.com/xml/</a>
  37. for more information.
  38. If you wish to use a different JAXP-compliant parser, you should remove
  39. <code>jaxp.jar</code> and <code>crimson.jar</code>
  40. from Ant's <code>lib</code> directory.
  41. You can then either put the jars from your preferred parser into Ant's
  42. <code>lib</code> directory or put the jars on the system classpath.</p>
  43. <p>
  44. For the current version of Ant, you will also need a JDK installed on
  45. your system, version 1.1 or later. A future version of Ant will require
  46. JDK 1.2 or later.
  47. </p>
  48. <hr>
  49. <h2><a name="installing">Installing Ant</a></h2>
  50. <p>The binary distribution of Ant consists of three directories:
  51. <code>bin</code>,
  52. <code>docs</code> and
  53. <code>lib</code>
  54. Only the <code>bin</code> and <code>lib</code> directories are
  55. required to run Ant.
  56. To install Ant, choose a directory and copy the distribution
  57. file there. This directory will be known as ANT_HOME.
  58. Before you can run ant there is some additional set up you
  59. will need to do:</p>
  60. <ul>
  61. <li>Add the <code>bin</code> directory to your path.</li>
  62. <li>Set the <code>ANT_HOME</code> environment variable to
  63. the directory where you installed Ant.</li>
  64. <li>Optionally, set the <code>JAVA_HOME</code> environment variable
  65. (see the <a href="#advanced">Advanced</a> section below).
  66. This should be set to the directory where your JDK is installed.</li>
  67. <li>If you are using Ant's optional tasks then you may need to add additional
  68. jars to your <code>lib</code> directory or to your CLASSPATH.
  69. See <a href="#librarydependencies">Library Dependencies</a>
  70. for for a list of jar requirements for various optional tasks.
  71. </li>
  72. </ul>
  73. <p><strong>Note:</strong> Do not install Ant's ant.jar file into the lib/ext
  74. directory of the JDK/JRE. Ant is an application, whilst the extension
  75. directory is intended for JDK extensions. In particular there are security
  76. restrictions on the classes which may be loaded by an extension.</p>
  77. <h3>Windows</h3>
  78. <p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the
  79. environment:</p>
  80. <pre>set ANT_HOME=c:\ant
  81. set JAVA_HOME=c:\jdk1.2.2
  82. set PATH=%PATH%;%ANT_HOME%\bin</pre>
  83. <h3>Unix (bash)</h3>
  84. <p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up
  85. the environment:</p>
  86. <pre>export ANT_HOME=/usr/local/ant
  87. export JAVA_HOME=/usr/local/jdk-1.2.2
  88. export PATH=${PATH}:${ANT_HOME}/bin</pre>
  89. <h3><a name="advanced">Advanced</a></h3>
  90. <p>There are lots of variants that can be used to run Ant. What you need is at
  91. least the following:</p>
  92. <ul>
  93. <li>The classpath for Ant must contain <code>ant.jar</code> and any jars/classes
  94. needed for your chosen JAXP-compliant XML parser.</li>
  95. <li>When you need JDK functionality
  96. (such as for the <a href="CoreTasks/javac.html">javac</a> task or the
  97. <a href="CoreTasks/rmic.html">rmic</a> task), then for JDK 1.1, the <code>classes.zip</code>
  98. file of the JDK must be added to the classpath; for JDK 1.2 or JDK 1.3, <code>tools.jar</code>
  99. must be added. The scripts supplied with Ant,
  100. in the <code>bin</code> directory, will add
  101. the required JDK classes automatically, if the <code>JAVA_HOME</code>
  102. environment variable is set.</li>
  103. <li>When you are executing platform-specific applications, such as the
  104. <a href="CoreTasks/exec.html">exec</a> task or the
  105. <a href="CoreTasks/cvs.html">cvs</a> task, the property <code>ant.home</code>
  106. must be set to the directory containing where you installed Ant. Again
  107. this is set by the Ant scripts to the value of the ANT_HOME environment
  108. variable.</li>
  109. </ul>
  110. <hr>
  111. <h2><a name="buildingant">Building Ant</a></h2>
  112. <p>To build Ant from source, you can either install the Ant source distribution
  113. or checkout the jakarta-ant module from CVS.</p>
  114. <p>Once you have installed the source, change into the installation
  115. directory.</p>
  116. <p>Set the <code>JAVA_HOME</code> environment variable
  117. to the directory where the JDK is installed.
  118. See <a href="#installing">Installing Ant</a>
  119. for examples on how to do this for your operating system. </p>
  120. <p>Make sure you have downloaded any auxiliary jars required to
  121. build tasks you are interested in. These should either be available
  122. on the CLASSPATH or added to the <code>lib/optional</code>
  123. directory.
  124. See <a href="#librarydependencies">Library Dependencies</a>
  125. for a list of jar requirements for various features.
  126. Note that this will make the auxiliary jars
  127. available for the building of Ant only. For running Ant you will
  128. still need to
  129. make the jars available as described under
  130. <a href="#installing">Installing Ant</a>.</p>
  131. <p>Your are now ready to build Ant:</p>
  132. <blockquote>
  133. <p><code>build -Ddist.dir=&lt;<i>directory_to_contain_Ant_distribution</i>&gt; dist</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  134. <p><code>build.sh -Ddist.dir=&lt;<i>directory_to_contain_Ant_distribution</i>&gt; dist</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  135. </blockquote>
  136. <p>This will create a binary distribution of Ant in the directory you specified.</p>
  137. <p>The above action does the following:</p>
  138. <ul>
  139. <li>If necessary it will bootstrap the Ant code. Bootstrapping involves the manual
  140. compilation of enough Ant code to be able to run Ant. The bootstrapped Ant is
  141. used for the remainder of the build steps. </li>
  142. <li>Invokes the bootstrapped Ant with the parameters passed to the build script. In
  143. this case, these parameters define an Ant property value and specify the &quot;dist&quot; target
  144. in Ant's own <code>build.xml</code> file.
  145. </ul>
  146. <p>On most occasions you will not need to explicitly bootstrap Ant since the build
  147. scripts do that for you. If however, the build file you are using makes use of features
  148. not yet compiled into the bootstrapped Ant, you will need to manually bootstrap.
  149. Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX)
  150. to build a new bootstrap version of Ant.</p>
  151. If you wish to install the build into the current <code>ANT_HOME</code>
  152. directory, you can use:
  153. <blockquote>
  154. <p><code>build install</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  155. <p><code>build.sh install</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  156. </blockquote>
  157. You can avoid the lengthy Javadoc step, if desired, with:
  158. <blockquote>
  159. <p><code>build install-lite</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  160. <p><code>build.sh install-lite</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  161. </blockquote>
  162. This will only install the <code>bin</code> and <code>lib</code> directories.
  163. <p>Both the <code>install</code> and
  164. <code>install-lite</code> targets will overwrite
  165. the current Ant version in <code>ANT_HOME</code>.</p>
  166. <hr>
  167. <h2><a name="running">Running Ant</a></h2>
  168. <p>Running Ant is simple, when you installed it as described in the previous
  169. section. Just type <code>ant</code>.</p>
  170. <p>When nothing is specified, Ant looks for a <code>build.xml</code>
  171. file in the current directory. If found, it uses that file as the
  172. buildfile. If you use the <code>-find</code> option,
  173. Ant will search for a buildfile in
  174. the parent directory, and so on, until the root of the filesystem
  175. has been reached. To make Ant use
  176. another buildfile, use the command-line
  177. option <code>-buildfile <i>file</i></code>,
  178. where <i>file</i> is the buildfile you want to use.</p>
  179. <p>You can also set properties that override properties specified in the
  180. buildfile (see the <a href="CoreTasks/property.html">property</a> task).
  181. This can be done with
  182. the <nobr><code>-D<i>property</i>=<i>value</i></code></nobr> option,
  183. where <i>property</i> is the name of the property,
  184. and <i>value</i> is the value for that property.
  185. This can also be used to pass in the value of some environment variables.
  186. You can also access environment variables using the <a href="CoreTasks/property.html">
  187. property</a> task.
  188. Just pass <nobr><code>-DMYVAR=%MYVAR%</code></nobr> (Windows) or
  189. <nobr><code>-DMYVAR=$MYVAR</code></nobr> (Unix)
  190. to Ant - you can then access
  191. these variables inside your buildfile as <code>${MYVAR}</code>.</p>
  192. <p>Two more options are: <nobr><code>-quiet</code></nobr>,
  193. which instructs Ant to print less
  194. information on the console when running, and
  195. <nobr><code>-verbose</code></nobr>, which causes Ant to print
  196. additional information to the console.</p>
  197. <p>It is also possible to specify one or more targets that should be executed.
  198. When omitted, the target that is specified in the
  199. <code>default</code> attribute of the <code>&lt;project&gt;</code> tag is
  200. used.</p>
  201. <p>The <nobr><code>-projecthelp</code></nobr>
  202. option gives a list of this project's
  203. targets. First those with a description, then those without one.</p>
  204. <p>Command-line option summary:</p>
  205. <pre>ant [options] [target [target2 [target3] ...]]
  206. Options:
  207. -help print this message
  208. -projecthelp print project help information
  209. -version print the version information and exit
  210. -quiet be extra quiet
  211. -verbose be extra verbose
  212. -debug print debugging information
  213. -emacs produce logging information without adornments
  214. -logfile <i>file</i> use given file for log output
  215. -logger <i>classname</i> the class that is to perform logging
  216. -listener <i>classname</i> add an instance of class as a project listener
  217. -buildfile <i>file</i> use specified buildfile
  218. -find <i>file</i> search for buildfile towards the root of the filesystem and use the first one found
  219. -D<i>property</i>=<i>value</i> set <i>property</i> to <i>value</i>
  220. </pre>
  221. <h3>Examples</h3>
  222. <blockquote>
  223. <pre>ant</pre>
  224. </blockquote>
  225. <p>runs Ant using the <code>build.xml</code> file in the current directory, on
  226. the default target.</p>
  227. <blockquote>
  228. <pre>ant -buildfile test.xml</pre>
  229. </blockquote>
  230. <p>runs Ant using the <code>test.xml</code> file in the current directory, on
  231. the default target.</p>
  232. <blockquote>
  233. <pre>ant -buildfile test.xml dist</pre>
  234. </blockquote>
  235. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  236. target called <code>dist</code>.</p>
  237. <blockquote>
  238. <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre>
  239. </blockquote>
  240. <p>runs Ant using the <code>test.xml</code> file in the current directory, on a
  241. target called <code>dist</code>, setting the <code>build</code> property to the
  242. value <code>build/classes</code>.</p>
  243. <h3>Running Ant by Hand</h3>
  244. <p>If you have installed Ant in the do-it-yourself way, Ant can be started
  245. with:</p>
  246. <blockquote>
  247. <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre>
  248. </blockquote>
  249. <p>These instructions actually do exactly the same as the <code>ant</code>
  250. command. The options and target are the same as when running Ant with the <code>ant</code>
  251. command. This example assumes you have set your classpath to include:</p>
  252. <ul>
  253. <li><code>ant.jar</code></li>
  254. <li>jars/classes for your XML parser</li>
  255. <li>the JDK's required jar/zip files</li>
  256. </ul>
  257. <hr>
  258. <h2><a name="librarydependencies">Library Dependencies</a></h2>
  259. <p>The following libraries are needed in your CLASSPATH or in the
  260. install directory's <code>lib</code> directory if you are using the
  261. indicated feature. Note that only one of the regexp libraries is
  262. needed for use with the mappers.</p>
  263. <table border="1" cellpadding="2" cellspacing="0">
  264. <tr>
  265. <td><b>Jar Name</b></td>
  266. <td><b>Needed For</b></td>
  267. <td><b>Available At</b></td>
  268. </tr>
  269. <tr>
  270. <td>jakarta-regexp-1.2.jar</td>
  271. <td>regexp type with mappers</td>
  272. <td><a href="http://jakarta.apache.org/regexp/" target="_top">jakarta.apache.org/regexp/</a></td>
  273. </tr>
  274. <tr>
  275. <td>jakarta-oro-2.0.1.jar</td>
  276. <td>regexp type with mappers and the perforce tasks</td>
  277. <td><a href="http://jakarta.apache.org/oro/" target="_top">jakarta.apache.org/oro/</a></td>
  278. </tr>
  279. <tr>
  280. <td>junit.jar</td>
  281. <td>junit tasks</td>
  282. <td><a href="http://www.junit.org/" target="_top">www.junit.org</a></td>
  283. </tr>
  284. <tr>
  285. <td>stylebook.jar</td>
  286. <td>stylebook task</td>
  287. <td>CVS repository of <a href="http://xml.apache.org" target="_top">xml.apache.org</a></td>
  288. </tr>
  289. <tr>
  290. <td>testlet.jar</td>
  291. <td>test task</td>
  292. <td><a href="http://java.apache.org/framework" target="_top">java.apache.org/framework</a></td>
  293. </tr>
  294. <tr>
  295. <td>antlr.jar</td>
  296. <td>antlr task</td>
  297. <td><a href="http://www.antlr.org/" target="_top">www.antlr.org</a></td>
  298. </tr>
  299. <tr>
  300. <td >bsf.jar</td>
  301. <td>script task</td>
  302. <td><a href="http://oss.software.ibm.com/developerworks/projects/bsf" target="_top">
  303. oss.software.ibm.com/developerworks/projects/bsf</a></td>
  304. </tr>
  305. <tr>
  306. <td>netrexx.jar</td>
  307. <td>netrexx task</td>
  308. <td><a href="http://www2.hursley.ibm.com/netrexx" target="_top">
  309. www2.hursley.ibm.com/netrexx</a></td>
  310. </tr>
  311. <tr>
  312. <td>rhino.jar</td>
  313. <td>javascript with script task</td>
  314. <td><a href="http://www.mozilla.org/" target="_top">www.mozilla.org</a></td>
  315. </tr>
  316. <tr>
  317. <td>jpython.jar</td>
  318. <td>python with script task</td>
  319. <td><a href="http://www.jpython.org/" target="_top">www.jpython.org</a></td>
  320. </tr>
  321. <tr>
  322. <td>netcomponents.jar</td>
  323. <td>ftp and telnet tasks</td>
  324. <td><a href="http://www.savarese.org/oro/downloads/index.html#NetComponents"
  325. target="_top">www.savarese.org/oro/downloads</a></td>
  326. </tr>
  327. </table>
  328. <br>
  329. <hr>
  330. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  331. Reserved.</p>
  332. </body>
  333. </html>