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 37 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
  19. <title>Installing Ant</title>
  20. </head>
  21. <body>
  22. <h1>Installing Ant</h1>
  23. <h2><a name="getting">Getting Ant</a></h2>
  24. <h3>Download Area Layout</h3>
  25. <table>
  26. <tr>
  27. <th>Filename</th>
  28. <th>Description</th>
  29. </tr>
  30. <tr>
  31. <td>KEYS</td>
  32. <td>PGP-Keysfile. It contains the PGP-keys of Ant developers so you can 'trust' the distribution. </td>
  33. </tr>
  34. <tr>
  35. <td>RELEASE-NOTES-{version}.html</td>
  36. <td>
  37. Release notes of the given version in HTML format. When upgrading your Ant installation you
  38. should have a look on the <i>Changes that could break older environments</i> section.
  39. </td>
  40. </tr>
  41. <tr>
  42. <td>ant-current-bin.zip</td>
  43. <td>
  44. ZIP-Archive containing the compiled version of Ant in the last released version. This is the file
  45. most of the users want to have.
  46. </td>
  47. </tr>
  48. <tr>
  49. <td>ant-current-src.zip</td>
  50. <td>
  51. ZIP-Archive containing the sources of Ant. If you have this you could compile Ant itself.
  52. If you do not have the <i>required</i> dependencies, the classes depeding on them are just not
  53. build.
  54. </td>
  55. </tr>
  56. <tr>
  57. <td>ant-current-*.asc</td>
  58. <td>
  59. Security file for checking the correctness of the zip file. This one is the
  60. <a href="http://en.wikipedia.org/wiki/Pretty_Good_Privacy" target="_blank">PGP</a> key.
  61. </td>
  62. </tr>
  63. <tr>
  64. <td>ant-current-*.md5</td>
  65. <td>
  66. Security file for checking the correctness of the zip file. This one is the
  67. <a href="http://en.wikipedia.org/wiki/Md5" target="_blank">MD5</a> key.
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>ant-current-*.sha1</td>
  72. <td>
  73. Security file for checking the correctness of the zip file. This one is the
  74. <a href="http://en.wikipedia.org/wiki/SHA-1" target="_blank">SHA1</a> key.
  75. </td>
  76. </tr>
  77. </table>
  78. <h3>Binary Edition</h3>
  79. <p>The latest stable version of Ant is available from the Ant web page <a
  80. href="http://ant.apache.org/" target="_top">http://ant.apache.org/</a>.
  81. <h3>As a binary in an RPM Package</h3>
  82. <p>Consult the <a href="#jpackage">jpackage</a> section below.</p>
  83. <h3>Bundled in IDEs</h3>
  84. <p>
  85. All the main Java IDEs ship with Ant, products such as Eclipse, NetBeans
  86. and IntelliJ IDEA. If you install Ant this way you usually get the most recent
  87. release of Ant at the time the IDE was released. Some of the IDEs (Eclipse
  88. and NetBeans in particular) ship with extra tasks that only work if
  89. IDE-specific tools are on Ant's path. To use these on command-line versions
  90. of Ant, the relevant JARs need to be added to the command-line Ant as
  91. extra libraries/tasks. Note that if it is an IDE task or extension that is
  92. not behaving, the Ant team is unable to field bug reports. Try the IDE mailing
  93. lists first, who will cross-file bugs if appropriate.
  94. </p>
  95. <p>
  96. IDE's can invariably be pointed at different Ant installations. This lets
  97. developers upgrade to a new release of Ant, and eliminate inconsistencies
  98. between command-line and IDE Ant.
  99. </p>
  100. <h3>Bundled in Java applications</h3>
  101. <p>
  102. Many Java applications, most particularly application servers, ship with
  103. a version of Ant. These are primarily for internal use by the application,
  104. using the Java APIs to delegate tasks such as JSP page compilation to the Ant
  105. runtime. Such distributions are usually unsupported by everyone. Particularly
  106. troublesome are those products that non only ship with their own Ant release,
  107. they add their own version of ANT.BAT or ant.sh to the PATH. If Ant starts
  108. behaving wierdly after installing something, try the
  109. <a href="#diagnostics">diagnostics</a> advice.
  110. </p>
  111. <h3>Source Edition</h3>
  112. <p>If you prefer the source edition, you can download the source for the latest
  113. Ant release from
  114. <a href="http://ant.apache.org/srcdownload.cgi" target="_top">http://ant.apache.org/srcdownload.cgi</a>.
  115. If you prefer the leading-edge code, you can access
  116. the code as it is being developed via SVN. The Ant website has details on
  117. <a href="http://ant.apache.org/svn.html" target="_top">accessing SVN</a>.
  118. All bug fixes will go in against the HEAD of the source tree, and the first
  119. response to many bugreps will be "have you tried the latest version".
  120. Don't be afraid to download and build a prererelease edition, as everything
  121. other than new features are usually stable.
  122. </p>
  123. <p>
  124. See the section <a href="#buildingant">Building Ant</a> on how to
  125. build Ant from the source code.
  126. You can also access the
  127. <a href="http://svn.apache.org/viewcvs.cgi/ant/" target="_top">
  128. Ant SVN repository</a> on-line. </p>
  129. <hr>
  130. <h2><a name="sysrequirements">System Requirements</a></h2>
  131. Ant has been used successfully on many platforms, including Linux,
  132. commercial flavours of Unix such as Solaris and HP-UX,
  133. Windows NT-platforms, OS/2 Warp, Novell Netware 6, OpenVMS and MacOS X.
  134. The platforms used most for development are, in no particular order,
  135. Linux, MacOS X, Windows XP and Unix; these are therefore that platforms
  136. that tend to work best. As of Ant1.7, Windows 9x is no longer supported.
  137. <p>
  138. To build and use Ant, you must have a JAXP-compliant XML parser installed and
  139. available on your classpath, such as Xerces.</p>
  140. <p>
  141. The binary distribution of Ant includes the latest version of the
  142. <a href="http://xml.apache.org/xerces2-j/index.html" target="_top">Apache Xerces2</a> XML parser.
  143. Please see
  144. <a href="http://java.sun.com/xml/" target="_top">http://java.sun.com/xml/</a>
  145. for more information about JAXP.
  146. If you wish to use a different JAXP-compliant parser, you should remove
  147. <code>xercesImpl.jar</code> and <code>xml-apis.jar</code>
  148. from Ant's <code>lib</code> directory.
  149. <p>
  150. You can then either put the JARs of your preferred parser into Ant's
  151. <code>lib</code> directory or put the jars on the system classpath.
  152. Some parts of Ant will fail if you use an old parser, especially one
  153. that is not namespace-aware. In particular, avoid the Crimson parser.</p>
  154. <p>Tip: "ant -diagnostics" will list the XML parser used and its location.</p>
  155. <p>
  156. For the current version of Ant, you will also need a JDK installed on
  157. your system, version 1.2 or later required, 1.5 or later strongly recommended.
  158. The later the version of Java , the more Ant tasks you get.
  159. </p>
  160. <p>
  161. <strong>Note #2: </strong>If a JDK is not present, only the JRE runtime, then many tasks will not work.
  162. </p>
  163. <h3>Open Source Java Runtimes</h3>
  164. <p>
  165. The Ant team strongly supports users running Ant on Kaffe and other
  166. open source Java runtimes, and so strives to have a product that works
  167. well on those platforms. What appears to work well is Kaffe with
  168. Gnu Classpath and the Xerces and Xalan libraries.
  169. </p>
  170. <hr>
  171. <h2><a name="installing">Installing Ant</a></h2>
  172. <p>The binary distribution of Ant consists of the following directory layout:
  173. <pre>
  174. ant
  175. +--- README, LICENSE, fetch.xml, other text files. //basic information
  176. +--- bin // contains launcher scripts
  177. |
  178. +--- lib // contains Ant jars plus necessary dependencies
  179. |
  180. +--- docs // contains documentation
  181. | |
  182. | +--- images // various logos for html documentation
  183. | |
  184. | +--- manual // Ant documentation (a must read ;-)
  185. |
  186. +--- etc // contains xsl goodies to:
  187. // - create an enhanced report from xml output of various tasks.
  188. // - migrate your build files and get rid of 'deprecated' warning
  189. // - ... and more ;-)
  190. </pre>
  191. Only the <code>bin</code> and <code>lib</code> directories are
  192. required to run Ant.
  193. To install Ant, choose a directory and copy the distribution
  194. files there. This directory will be known as ANT_HOME.
  195. </p>
  196. <table width="80%">
  197. <tr>
  198. <td colspan="2">
  199. <b>Windows 95, Windows 98 &amp; Windows ME Note:</b>
  200. </td>
  201. </tr>
  202. <tr>
  203. <td width="5%">&nbsp;</td>
  204. <td><i>
  205. On these systems, the script used to launch Ant will have
  206. problems if ANT_HOME is a long filename (i.e. a filename which is not
  207. of the format known as &quot;8.3&quot;). This is due to
  208. limitations in the OS's handling of the <code>&quot;for&quot;</code>
  209. batch-file statement. It is recommended, therefore, that Ant be
  210. installed in a <b>short</b>, 8.3 path, such as C:\Ant. </i>
  211. </td>
  212. </tr>
  213. <tr>
  214. <td width="5%">&nbsp;</td>
  215. <td>
  216. <p>On these systems you will also need to configure more environment
  217. space to cater for the environment variables used in the Ant lauch script.
  218. To do this, you will need to add or update the following line in
  219. the <code>config.sys</code> file
  220. </p>
  221. <p><code>shell=c:\command.com c:\ /p /e:32768</code></p>
  222. </td>
  223. </tr>
  224. </table>
  225. <h3>Setup</h3>
  226. <p>
  227. Before you can run Ant there is some additional set up you
  228. will need to do unless you are installing the <a href="#jpackage">RPM
  229. version from jpackage.org</a>:</p>
  230. <ul>
  231. <li>Add the <code>bin</code> directory to your path.</li>
  232. <li>Set the <code>ANT_HOME</code> environment variable to the
  233. directory where you installed Ant. On some operating systems, Ant's
  234. startup scripts can guess <code>ANT_HOME</code> (Unix dialects and
  235. Windows NT/2000), but it is better to not rely on this behavior.</li>
  236. <li>Optionally, set the <code>JAVA_HOME</code> environment variable
  237. (see the <a href="#advanced">Advanced</a> section below).
  238. This should be set to the directory where your JDK is installed.</li>
  239. </ul>
  240. <p><strong>Note:</strong> Do not install Ant's ant.jar file into the lib/ext
  241. directory of the JDK/JRE. Ant is an application, whilst the extension
  242. directory is intended for JDK extensions. In particular there are security
  243. restrictions on the classes which may be loaded by an extension.</p>
  244. <table width="80%">
  245. <tr>
  246. <td colspan="2">
  247. <b>Windows Note:</b>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td width="5%">&nbsp;</td>
  252. <td>
  253. The ant.bat script makes use of three environment variables -
  254. ANT_HOME, CLASSPATH and JAVA_HOME. <b>Ensure</b> that ANT_HOME and JAVA_HOME variables are set,
  255. and that they do <b><u>not</u></b> have quotes (either
  256. ' or &quot;) and they do <b><u>not</u></b> end with \ or with /. CLASSPATH should be unset or
  257. empty.
  258. </td>
  259. </tr>
  260. </table>
  261. <h3><a name="checkInstallation">Check Installation</a></h3>
  262. <p>You can check the basic installation with opening a new shell and typing <tt>ant</tt>. You
  263. should get a message like this
  264. <pre>
  265. Buildfile: build.xml does not exist!
  266. Build failed
  267. </pre>
  268. So Ant works. This message is there because you need to write an individual buildfile for your
  269. project. With a <tt>ant -version</tt> you should get an output like
  270. <pre>
  271. Apache Ant version 1.7.0 compiled on December 13 2006
  272. </pre>
  273. </p>
  274. <h3><a name="optionalTasks">Optional Tasks</a></h3>
  275. <p>Ant supports a number of optional tasks. An optional task is a task which
  276. typically requires an external library to function. The optional tasks are
  277. packaged together with the core Ant tasks.</p>
  278. <p>The external libraries required by each of the optional tasks is detailed
  279. in the <a href="#librarydependencies">Library Dependencies</a> section. These external
  280. libraries must be added to Ant's classpath, in any of the following ways:
  281. </p>
  282. <ul>
  283. <li><p>
  284. In <code><i>ANT_HOME</i>/lib</code>. This makes the JAR files available to all
  285. Ant users and builds.
  286. </p></li>
  287. <li><p>
  288. In <code>${user.home}/.ant/lib</code> (as of Ant 1.6). This
  289. allows different users to add new libraries to Ant. All JAR files
  290. added to this directory are available to command-line Ant.
  291. </p></li>
  292. <li><p>
  293. On the command line with a <code>-lib</code> parameter. This lets
  294. you add new JAR files on a case-by-case basis.
  295. </p></li>
  296. <li><p>
  297. In the <code>CLASSPATH</code> environment variable. Avoid this; it makes
  298. the JAR files visible to <i>all</i> Java applications, and causes
  299. no end of support calls. See <a href="#classpath">below</a> for details.
  300. </p>
  301. </li>
  302. <li><p>
  303. In some <code>&lt;classpath&gt;</code> accepted by the task itself.
  304. For example, as of Ant 1.7.0 you can run the <code>&lt;junit&gt;</code>
  305. task without <code>junit.jar</code> in Ant's own classpath, so long as
  306. it is included (along with your program and tests) in the classpath
  307. passed when running the task.
  308. </p><p>
  309. Where possible, this option is generally
  310. to be preferred, as the Ant script itself can determine the best path
  311. to load the library from: via relative path from the basedir (if you
  312. keep the library under version control with your project), according
  313. to Ant properties, environment variables, Ivy downloads, whatever you like.
  314. </p></li>
  315. </ul>
  316. <p>
  317. IDEs have different ways of adding external JAR files and third-party tasks
  318. to Ant. Usually it is done by some configuration dialog. Sometimes JAR files
  319. added to a project are automatically added to ant's classpath.
  320. </p>
  321. <h3><a name="classpath">The <code>CLASSPATH</code> environment variable</a></h3>
  322. <p>
  323. The <code>CLASSPATH</code> environment variable is a source of many Ant support queries. As
  324. the round trip time for diagnosis on the Ant user mailing list can be slow, and
  325. because filing bug reports complaining about 'ant.bat' not working will be
  326. rejected by the developers as WORKSFORME "this is a configuration problem, not a
  327. bug", you can save yourself a lot of time and frustration by following some
  328. simple steps.
  329. </p>
  330. <ol>
  331. <li>Do not ever set <code>CLASSPATH</code>. Ant does not need it, it only causes confusion
  332. and breaks things.
  333. </li>
  334. <li>If you ignore the previous rule, do not ever, ever, put quotes in the
  335. <code>CLASSPATH</code>, even if there is a space in a directory. This will break Ant, and it
  336. is not needed. </li>
  337. <li>If you ignore the first rule, do not ever, ever, have a trailing backslash
  338. in a <code>CLASSPATH</code>, as it breaks Ant's ability to quote the string. Again, this is
  339. not needed for the correct operation of the <code>CLASSPATH</code> environment variable, even
  340. if a DOS directory is to be added to the path. </li>
  341. <li>You can stop Ant using the <code>CLASSPATH</code> environment variable by setting the
  342. <code>-noclasspath</code> option on the command line. This is an easy way
  343. to test for classpath-related problems.</li>
  344. </ol>
  345. <p>
  346. The usual symptom of <code>CLASSPATH</code> problems is that ant will not run with some error
  347. about not being able to find <code>org.apache.tools.ant.launch.Launcher</code>, or, if you have got the
  348. quotes/backslashes wrong, some very weird Java startup error. To see if this is
  349. the case, run <code>ant -noclasspath</code> or unset the <code>CLASSPATH</code> environment
  350. variable.
  351. </p>
  352. <p>
  353. You can also make your Ant script reject this environment
  354. variable just by placing the following at the top of the script (or in an init target):
  355. </p>
  356. <pre>
  357. &lt;property environment="env."/&gt;
  358. &lt;property name="env.CLASSPATH" value=""/&gt;
  359. &lt;fail message="Unset $CLASSPATH / %CLASSPATH% before running Ant!"&gt;
  360. &lt;condition&gt;
  361. &lt;not&gt;
  362. &lt;equals arg1="${env.CLASSPATH}" arg2=""/&gt;
  363. &lt;/not&gt;
  364. &lt;/condition&gt;
  365. &lt;/fail&gt;
  366. </pre>
  367. <h3><a name="proxy">Proxy Configuration</a></h3>
  368. <p> Many Ant built-in and third-party tasks use network connections to retrieve
  369. files from HTTP servers. If you are behind a firewall with a proxy server, then
  370. Ant needs to be configured with the proxy. Here are the different ways to do
  371. this. </p>
  372. <ul>
  373. <li><b>With Java1.5</b><br>
  374. When you run Ant on Java1.5, you could try to use the automatic proxy setup
  375. mechanism with <code>-autoproxy</code>.
  376. </li>
  377. <li><b>With explicit JVM properties.</b><br>
  378. These are documented <a
  379. href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html" target="_top">by Sun</a>,
  380. and control the proxy behaviour of the entire JVM. To set them in Ant, declare
  381. them in the <code>ANT_OPTS</code> environment variable. This is the best option
  382. for a non-mobile system. For a laptop, you have to change these settings as you
  383. roam.
  384. </li>
  385. <li><b>In the build file itself</b><br>
  386. If you are writing an build file that is always to be used behind the firewall,
  387. the &lt;setproxy&gt; task lets you configure the proxy (which it does by setting
  388. the JVM properties). If you do this, we strongly recommend using ant properties
  389. to define the proxy host, port, etc, so that individuals can override the
  390. defaults.</li>
  391. </ul>
  392. <p> The Ant team acknowledges that this is unsatisfactory. Until the JVM
  393. automatic proxy setup works properly everywhere, explicit JVM options via
  394. ANT_ARGS are probably the best solution. Setting properties on Ant's
  395. command line do not work, because those are <i>Ant properties</i> being set, not
  396. JVM options. This means the following does not set up the command line:
  397. </p>
  398. <pre>ant -Dhttp.proxyHost=proxy -Dhttp.proxyPort=81</pre>
  399. <p> All it does is set up two Ant properties.</p>
  400. <p>One other troublespot with
  401. proxies is with authenticating proxies. Ant cannot go beyond what the JVM does
  402. here, and as it is very hard to remotely diagnose, test and fix proxy-related
  403. problems, users who work behind a secure proxy will have to spend much time
  404. configuring the JVM properties until they are happy. </p>
  405. <h3><a name="windows">Windows and OS/2</a></h3>
  406. <p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the
  407. environment:</p>
  408. <pre>set ANT_HOME=c:\ant
  409. set JAVA_HOME=c:\jdk-1.5.0.05
  410. set PATH=%PATH%;%ANT_HOME%\bin</pre>
  411. <h3>Linux/Unix (bash)</h3>
  412. <p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up
  413. the environment:</p>
  414. <pre>export ANT_HOME=/usr/local/ant
  415. export JAVA_HOME=/usr/local/jdk-1.5.0.05
  416. export PATH=${PATH}:${ANT_HOME}/bin</pre>
  417. <h3>Linux/Unix (csh)</h3>
  418. <pre>setenv ANT_HOME /usr/local/ant
  419. setenv JAVA_HOME /usr/local/jdk/jdk-1.5.0.05
  420. set path=( $path $ANT_HOME/bin )</pre>
  421. <p>
  422. Having a symbolic link set up to point to the JVM/JSK version makes updates more seamless. </p>
  423. <a name="jpackage"></a>
  424. <h3>RPM version from jpackage.org</h3>
  425. <p>
  426. The <a href="http://www.jpackage.org" target="_top">JPackage project</a> distributes an RPM version of Ant.
  427. With this version, it is not necessary to set <code> JAVA_HOME </code>or
  428. <code> ANT_HOME </code>environment variables and the RPM installer will correctly
  429. place the Ant executable on your path.
  430. </p>
  431. <p>
  432. <b>NOTE:</b> <em>Since Ant 1.7.0</em>, if the <code>ANT_HOME</code>
  433. environment variable is set, the jpackage distribution will be
  434. ignored.
  435. </p>
  436. <p>
  437. Optional jars for the JPackage version are handled in two ways. The easiest, and
  438. best way is to get these external libraries from JPackage if JPackage has them
  439. available. (Note: for each such library, you will have to get both the external
  440. package itself (e.g. <code>oro-2.0.8-2jpp.noarch.rpm</code>) and the small library that links
  441. ant and the external package (e.g. <code>ant-apache-oro-1.6.2-3jpp.noarch.rpm</code>).
  442. </p><p>
  443. However, JPackage does not package proprietary software, and since some of the
  444. optional packages depend on proprietary jars, they must be handled as follows.
  445. This may violate the spirit of JPackage, but it is necessary if you need these proprietary packages.
  446. For example, suppose you want to install support for starteam, which jpackage does not
  447. support:
  448. <ol>
  449. <li>Decide where you want to deploy the extra jars. One option is in <code>$ANT_HOME/lib</code>,
  450. which, for JPackage is usually <code>/usr/share/ant/lib</code>. Another, less messy option
  451. is to create an <code>.ant/lib</code> subdirectory of your home directory and place your
  452. non-jpackage ant jars there, thereby avoiding mixing jpackage
  453. libraries with non-jpacakge stuff in the same folder.
  454. More information on where Ant finds its libraries is available
  455. <a href="http://ant.apache.org/manual/running.html#libs">here</a></li>
  456. <li>Download a non-jpackage binary distribution from the regular
  457. <a href="http://ant.apache.org/bindownload.cgi" target="_top">Apache Ant site</a></li>
  458. <li>Unzip or untar the distribution into a temporary directory</li>
  459. <li>Copy the linking jar, in this case <code>ant-starteam.jar</code>, into the library directory you
  460. chose in step 1 above.</li>
  461. <li>Copy the proprietary jar itself into the same directory.</li>
  462. </ol>
  463. Finally, if for some reason you are running on a system with both the JPackage and Apache versions of Ant
  464. available, if you should want to run the Apache version (which will have to be specified with an absolute file name,
  465. not found on the path), you should use Ant's <code>--noconfig</code> command-line switch to avoid JPackage's classpath mechanism.
  466. <h3><a name="advanced">Advanced</a></h3>
  467. <p>There are lots of variants that can be used to run Ant. What you need is at
  468. least the following:</p>
  469. <ul>
  470. <li>The classpath for Ant must contain <code>ant.jar</code> and any jars/classes
  471. needed for your chosen JAXP-compliant XML parser.</li>
  472. <li>When you need JDK functionality
  473. (such as for the <a href="CoreTasks/javac.html">javac</a> task or the
  474. <a href="CoreTasks/rmic.html">rmic</a> task), then <code>tools.jar</code>
  475. must be added. The scripts supplied with Ant,
  476. in the <code>bin</code> directory, will add
  477. the required JDK classes automatically, if the <code>JAVA_HOME</code>
  478. environment variable is set.</li>
  479. <li>When you are executing platform-specific applications, such as the
  480. <a href="CoreTasks/exec.html">exec</a> task or the
  481. <a href="CoreTasks/cvs.html">cvs</a> task, the property <code>ant.home</code>
  482. must be set to the directory containing where you installed Ant. Again
  483. this is set by the Ant scripts to the value of the ANT_HOME environment
  484. variable.</li>
  485. </ul>
  486. The supplied ant shell scripts all support an <tt>ANT_OPTS</tt>
  487. environment variable which can be used to supply extra options
  488. to ant. Some of the scripts also read in an extra script stored
  489. in the users home directory, which can be used to set such options. Look
  490. at the source for your platform's invocation script for details.
  491. <hr>
  492. <h2><a name="buildingant">Building Ant</a></h2>
  493. <p>To build Ant from source, you can either install the Ant source distribution
  494. or checkout the ant module from SVN.</p>
  495. <p>Once you have installed the source, change into the installation
  496. directory.</p>
  497. <p>Set the <code>JAVA_HOME</code> environment variable
  498. to the directory where the JDK is installed.
  499. See <a href="#installing">Installing Ant</a>
  500. for examples on how to do this for your operating system. </p>
  501. <p><b>Note</b>: The bootstrap process of Ant requires a greedy
  502. compiler like Sun's javac or jikes. It does not work with gcj or
  503. kjc.</p>
  504. <p>Make sure you have downloaded any auxiliary jars required to
  505. build tasks you are interested in. These should be
  506. added to the <code>lib/optional</code>
  507. directory of the source tree.
  508. See <a href="#librarydependencies">Library Dependencies</a>
  509. for a list of JAR requirements for various features.
  510. Note that this will make the auxiliary JAR
  511. available for the building of Ant only. For running Ant you will
  512. still need to
  513. make the JARs available as described under
  514. <a href="#installing">Installing Ant</a>.</p>
  515. <p>Your are now ready to build Ant:</p>
  516. <blockquote>
  517. <p><code>build -Ddist.dir=&lt;<i>directory_to_contain_Ant_distribution</i>&gt; dist</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  518. <p><code>sh build.sh -Ddist.dir=&lt;<i>directory_to_contain_Ant_distribution</i>&gt; dist</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  519. </blockquote>
  520. <p>This will create a binary distribution of Ant in the directory you specified.</p>
  521. <p>The above action does the following:</p>
  522. <ul>
  523. <li>If necessary it will bootstrap the Ant code. Bootstrapping involves the manual
  524. compilation of enough Ant code to be able to run Ant. The bootstrapped Ant is
  525. used for the remainder of the build steps. </li>
  526. <li>Invokes the bootstrapped Ant with the parameters passed to the build script. In
  527. this case, these parameters define an Ant property value and specify the &quot;dist&quot; target
  528. in Ant's own <code>build.xml</code> file.</li>
  529. <li>Create the ant.jar and ant-launcher.jar JAR files</li>
  530. <li>Create optional JARs for which the build had the relevant libraries. If
  531. a particular library is missing from ANT_HOME/lib/optional, then the matching
  532. ant- JAR file will not be created. For example, ant-junit.jar is only built
  533. if there is a junit.jar in the optional directory.</li>
  534. </ul>
  535. <p>On most occasions you will not need to explicitly bootstrap Ant since the build
  536. scripts do that for you. If however, the build file you are using makes use of features
  537. not yet compiled into the bootstrapped Ant, you will need to manually bootstrap.
  538. Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX)
  539. to build a new bootstrap version of Ant.</p>
  540. If you wish to install the build into the current <code>ANT_HOME</code>
  541. directory, you can use:
  542. <blockquote>
  543. <p><code>build install</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  544. <p><code>sh build.sh install</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  545. </blockquote>
  546. You can avoid the lengthy Javadoc step, if desired, with:
  547. <blockquote>
  548. <p><code>build install-lite</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Windows</i>)</p>
  549. <p><code>sh build.sh install-lite</code>&nbsp;&nbsp;&nbsp;&nbsp;(<i>Unix</i>)</p>
  550. </blockquote>
  551. This will only install the <code>bin</code> and <code>lib</code> directories.
  552. <p>Both the <code>install</code> and
  553. <code>install-lite</code> targets will overwrite
  554. the current Ant version in <code>ANT_HOME</code>.</p>
  555. <hr>
  556. <h2><a name="librarydependencies">Library Dependencies</a></h2>
  557. <p>The following libraries are needed in Ant's classpath
  558. if you are using the
  559. indicated feature. Note that only one of the regexp libraries is
  560. needed for use with the mappers
  561. (and Java 1.4 and higher includes a regexp implementation which
  562. Ant will find automatically).
  563. You will also need to install the particular
  564. Ant optional jar containing the task definitions to make these
  565. tasks available. Please refer to the <a href="#optionalTasks">
  566. Installing Ant / Optional Tasks</a> section above.</p>
  567. <table border="1" cellpadding="2" cellspacing="0">
  568. <tr>
  569. <td><b>Jar Name</b></td>
  570. <td><b>Needed For</b></td>
  571. <td><b>Available At</b></td>
  572. </tr>
  573. <tr>
  574. <td>An XSL transformer like Xalan</td>
  575. <td>style task</td>
  576. <td>
  577. <b>If you use JDK 1.4+, an XSL transformer is already included, so you need not do anything special.</b><br>
  578. <ul><li>XALAN : <a href="http://xml.apache.org/xalan-j/index.html"
  579. target="_top">http://xml.apache.org/xalan-j/index.html</a></li>
  580. </ul>
  581. </td>
  582. </tr>
  583. <tr>
  584. <td>jakarta-regexp-1.3.jar</td>
  585. <td>regexp type with mappers</td>
  586. <td><a href="http://jakarta.apache.org/regexp/" target="_top">http://jakarta.apache.org/regexp/</a></td>
  587. </tr>
  588. <tr>
  589. <td>jakarta-oro-2.0.8.jar</td>
  590. <td>regexp type with mappers and the perforce tasks<br>
  591. To use the FTP task,
  592. you need jakarta-oro 2.0.8 or later, and <a href="#commons-net">commons-net</a></td>
  593. <td><a href="http://jakarta.apache.org/oro/" target="_top">http://jakarta.apache.org/oro/</a></td>
  594. </tr>
  595. <tr>
  596. <td>junit.jar</td>
  597. <td><code>&lt;junit&gt;</code> task. May be in classpath passed to task rather than Ant's classpath.</td>
  598. <td><a href="http://www.junit.org/" target="_top">http://www.junit.org/</a></td>
  599. </tr>
  600. <tr>
  601. <td>xalan.jar</td>
  602. <td>junitreport task</td>
  603. <td><a href="http://xml.apache.org/xalan-j/" target="_top">http://xml.apache.org/xalan-j/</a></td>
  604. </tr>
  605. <tr>
  606. <td>stylebook.jar</td>
  607. <td>stylebook task</td>
  608. <td>SVN repository of <a href="http://xml.apache.org/svn.html" target="_top">http://xml.apache.org/svn.html</a></td>
  609. </tr>
  610. <tr>
  611. <td>antlr.jar</td>
  612. <td>antlr task</td>
  613. <td><a href="http://www.antlr.org/" target="_top">http://www.antlr.org/</a></td>
  614. </tr>
  615. <tr>
  616. <td>bsf.jar</td>
  617. <td>script task
  618. <p>
  619. <strong>Note</strong>: Ant 1.6 and later require Apache BSF, not
  620. the IBM version. I.e. you need BSF 2.3.0-rc1 or later.
  621. </p>
  622. <p>
  623. <strong>Note</strong>: BSF 2.4.0 is needed to use a post 1.5R3 version
  624. of rhino's javascript.
  625. </p>
  626. <p>
  627. <strong>Note</strong>: BSF 2.4.0 uses jakarata-commons-logging
  628. so it needs the commons-logging.jar.
  629. </p>
  630. </td>
  631. <td><a href="http://jakarta.apache.org/bsf/" target="_top">http://jakarta.apache.org/bsf/</a></td>
  632. </tr>
  633. <tr>
  634. <td>Groovy jars</td>
  635. <td>Groovy with script and scriptdef tasks<br>
  636. You need to get the groovy jar and two asm jars from a groovy
  637. installation. The jars are groovy-[version].jar, asm-[vesion].jar and
  638. asm-util-[version].jar and antlr-[version].jar.
  639. As of groovy version 1.0-JSR-06, the jars are
  640. groovy-1.0-JSR-06.jar, antlr-2.7.5.jar, asm-2.2.jar and asm-util-2.2.jar.
  641. Alternatively one may use the embedded groovy jar file.
  642. This is located in the embedded directory of the groovy distribution.
  643. This bundles all the needed jar files into one jar file.
  644. It is called groovy-all-[version].jar.
  645. </td>
  646. <td>
  647. <a href="http://groovy.codehaus.org/" target="_top">http://groovy.codehaus.org/</a>
  648. <br>
  649. The asm jars are also available from the creators of asm -
  650. <a href="http://asm.objectweb.org/" target="_top">http://asm.objectweb.org/</a>
  651. </td>
  652. </tr>
  653. <tr>
  654. <td>netrexx.jar</td>
  655. <td>netrexx task, Rexx with the script task</td>
  656. <td><a href="http://www.ibm.com/software/awdtools/netrexx/download.html" target="_top">
  657. http://www.ibm.com/software/awdtools/netrexx/download.html</a></td>
  658. </tr>
  659. <tr>
  660. <td>js.jar</td>
  661. <td>Javascript with script task<br>
  662. If you use Apache BSF 2.3.0-rc1, you must use rhino 1.5R3 (later
  663. versions of BSF (e.g. version 2.4.0) work with 1.5R4 and higher).</td>
  664. <td><a href="http://www.mozilla.org/rhino/" target="_top">http://www.mozilla.org/rhino/</a></td>
  665. </tr>
  666. <tr>
  667. <td>jython.jar</td>
  668. <td>Python with script task<br>
  669. Warning : jython.jar also contains classes from jakarta-oro.
  670. Remove these classes if you are also using jakarta-oro.</td>
  671. <td><a href="http://jython.sourceforge.net/" target="_top">http://jython.sourceforge.net/</a></td>
  672. </tr>
  673. <tr>
  674. <td>jpython.jar</td>
  675. <td>Python with script task <b>deprecated, jython is the prefered engine</b></td>
  676. <td><a href="http://www.jpython.org/" target="_top">http://www.jpython.org/</a></td>
  677. </tr>
  678. <tr>
  679. <td>jacl.jar and tcljava.jar</td>
  680. <td>TCL with script task</td>
  681. <td><a href="http://www.scriptics.com/software/java/" target="_top">http://www.scriptics.com/software/java/</a></td>
  682. </tr>
  683. <tr>
  684. <td>BeanShell JAR(s)</td>
  685. <td>BeanShell with script task.
  686. <br>
  687. <strong>Note</strong>: Ant requires BeanShell version 1.3 or
  688. later</td>
  689. <td><a href="http://www.beanshell.org/" target="_top">http://www.beanshell.org/</a></td>
  690. </tr>
  691. <tr>
  692. <td>jruby.jar</td>
  693. <td>Ruby with script task</td>
  694. <td><a href="http://jruby.sourceforge.net/" target="_top">http://jruby.sourceforge.net/</a></td>
  695. </tr>
  696. <tr>
  697. <td>judo.jar</td>
  698. <td>Judoscript with script task</td>
  699. <td><a href="http://www.judoscript.com/index.html" target="_top">http://www.judoscript.com/index.html</a></td>
  700. </tr>
  701. <tr>
  702. <td>commons-logging.jar</td>
  703. <td>CommonsLoggingListener</td>
  704. <td><a href="http://jakarta.apache.org/commons/logging/index.html"
  705. target="_top">http://jakarta.apache.org/commons/logging/index.html</a></td>
  706. </tr>
  707. <tr>
  708. <td>log4j.jar</td>
  709. <td>Log4jListener</td>
  710. <td><a href="http://jakarta.apache.org/log4j/docs/index.html"
  711. target="_top">http://jakarta.apache.org/log4j/docs/index.html</a></td>
  712. </tr>
  713. <tr>
  714. <td><a name="commons-net">commons-net.jar</a></td>
  715. <td>ftp, rexec and telnet tasks<br>
  716. jakarta-oro 2.0.8 or later is required together with commons-net 1.4.0.<br>
  717. For all users, a minimum version of commons-net of 1.4.0 is recommended. Earlier
  718. versions did not support the full range of configuration options, and 1.4.0 is needed
  719. to compile Ant.
  720. </td>
  721. <td><a href="http://jakarta.apache.org/commons/net/index.html"
  722. target="_top">http://jakarta.apache.org/commons/net/index.html</a></td>
  723. </tr>
  724. <tr>
  725. <td>bcel.jar</td>
  726. <td>classfileset data type,
  727. JavaClassHelper used by the ClassConstants filter reader and
  728. optionally used by ejbjar for dependency determination
  729. </td>
  730. <td><a href="http://jakarta.apache.org/bcel/" target="_top">http://jakarta.apache.org/bcel/</a></td>
  731. </tr>
  732. <tr>
  733. <td>mail.jar</td>
  734. <td>Mail task with Mime encoding, and the MimeMail task</td>
  735. <td><a href="http://java.sun.com/products/javamail/"
  736. target="_top">http://java.sun.com/products/javamail/</a></td>
  737. </tr>
  738. <tr>
  739. <td>jsse.jar</td>
  740. <td>
  741. Support for SMTP over TLS/SSL <br>
  742. in the Mail task<br>
  743. Already included Java 1.4+</td>
  744. <td><a href="http://java.sun.com/products/jsse/"
  745. target="_top">http://java.sun.com/products/jsse/</a></td>
  746. </tr>
  747. <tr>
  748. <td>activation.jar</td>
  749. <td>Mail task with Mime encoding, and the MimeMail task</td>
  750. <td><a href="http://java.sun.com/products/javabeans/glasgow/jaf.html"
  751. target="_top">http://java.sun.com/products/javabeans/glasgow/jaf.html</a></td>
  752. </tr>
  753. <tr>
  754. <td>jdepend.jar</td>
  755. <td>jdepend task</td>
  756. <td><a href="http://www.clarkware.com/software/JDepend.html"
  757. target="_top">http://www.clarkware.com/software/JDepend.html</a></td>
  758. </tr>
  759. <tr>
  760. <td>resolver.jar <b>1.1beta or later</b></td>
  761. <td>xmlcatalog datatype <em>only if support for external catalog files is desired</em></td>
  762. <td><a href="http://xml.apache.org/commons/"
  763. target="_top">http://xml.apache.org/commons/</a>.</td>
  764. </tr>
  765. <tr>
  766. <td>jsch.jar <b>0.1.29 or later</b></td>
  767. <td>sshexec and scp tasks</td>
  768. <td><a href="http://www.jcraft.com/jsch/index.html"
  769. target="_top">http://www.jcraft.com/jsch/index.html</a></td>
  770. </tr>
  771. <tr>
  772. <td>JAI - Java Advanced Imaging</td>
  773. <td>image task</td>
  774. <td><a href="http://java.sun.com/products/java-media/jai/"
  775. target="_top">http://java.sun.com/products/java-media/jai/</a></td>
  776. </tr>
  777. <tr>
  778. <td>Starteam SDK</td>
  779. <td>Starteam version management tasks</td>
  780. <td><a href="http://www.borland.com/downloads/download_starteam.html"
  781. target="_top">http://www.borland.com/downloads/download_starteam.html</a></td>
  782. </tr>
  783. </table>
  784. <br>
  785. <h2><a name="Troubleshooting">Troubleshooting</a></h2>
  786. <h3><a name="diagnostics">Diagnostics</a></h3>
  787. <p> Ant has a built in diagnostics feature. If you run <code>ant
  788. -diagnostics</code> ant will look at its internal state and print it out. This
  789. code will check and print the following things. </p>
  790. <ul>
  791. <li>Where Ant is running from. Sometimes you can be surprised.</li>
  792. <li>The version of ant.jar and of the ant-*.jar containing the optional tasks -
  793. and whether they match</li>
  794. <li>Which JAR files are in ANT_HOME/lib
  795. <li>Which optional tasks are available. If a task is not listed as being
  796. available, either it is not present, or libraries that it depends on are
  797. absent.</li>
  798. <li>XML Parser information</li>
  799. <li>JVM system properties
  800. </li>
  801. <li>The status of the temp directory. If this is not writeable, or its clock is
  802. horribly wrong (possible if it is on a network drive), a lot of tasks will fail
  803. with obscure error messages.</li>
  804. <li>The current time zone as Java sees it. If this is not what it should be for
  805. your location, then dependency logic may get confused.
  806. </ul>
  807. <p>
  808. Running <code>ant -diagnostics</code> is a good way to check that ant is
  809. installed. It is also a first step towards self-diagnosis of any problem.
  810. Any configuration problem reported to the user mailing list will probably
  811. result ins someone asking you to run the command and show the results, so
  812. save time by using it yourself.
  813. </p>
  814. <p>
  815. For under-IDE diagostics, use the &lt;diagnostics&gt; task to run the same
  816. tests as an ant task. This can be added to a diagnostics target in a build
  817. file to see what tasks are available under the IDE, what the XML parser and
  818. classpath is, etc.
  819. </p>
  820. <h3><a name="ant-user">user mailing list</a></h3>
  821. <p> If you cannot get Ant installed or working, the Ant user mailing list is the
  822. best place to start with any problem. Please do your homework first, make sure
  823. that it is not a <a href="#classpath"><code>CLASSPATH</code></a> problem, and run a <a
  824. href="#diagnostics">diagnostics check</a> to see what Ant thinks of its own
  825. state. Why the user list, and not the developer list?
  826. Because there are more users than developers, so more people who can help you. </p>
  827. <p>
  828. Please only file a bug report against Ant for a configuration/startup problem if
  829. there really is a fixable bug in Ant related to configuration, such as it not
  830. working on a particular platform, with a certain JVM version, etc, or if you are
  831. advised to do it by the user mailing list.
  832. </p>
  833. </body>
  834. </html>