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.

faq.xml 48 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. <?xml version="1.0"?>
  2. <document>
  3. <properties>
  4. <author email="bodewig@apache.org">Stefan Bodewig</author>
  5. <title>Frequently Asked Questions</title>
  6. </properties>
  7. <faqsection title="About this FAQ">
  8. <faq id="latest-version">
  9. <question>Where do I find the latest version of this
  10. document?</question>
  11. <answer>
  12. <p>The latest version can always be found at Ant&apos;s homepage
  13. <a href="http://ant.apache.org/faq.html">http://ant.apache.org/faq.html</a>.</p>
  14. </answer>
  15. </faq>
  16. <faq id="adding-faqs">
  17. <question>How can I contribute to this FAQ?</question>
  18. <answer>
  19. <p>The page you are looking it is generated from
  20. <a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/ant/xdocs/faq.xml">this</a>
  21. document. If you want to add a new question, please submit
  22. a patch against this document to one of Ant&apos;s mailing lists;
  23. hopefully, the structure is self-explanatory.</p>
  24. <p>If you don&apos;t know how to create a patch, see the patches
  25. section of <a href="http://jakarta.apache.org/site/source.html">this
  26. page</a>.</p>
  27. </answer>
  28. </faq>
  29. <faq id="creating-faq">
  30. <question>How do you create the HTML version of this
  31. FAQ?</question>
  32. <answer>
  33. <p>We use
  34. <a href="http://jakarta.apache.org/velocity/anakia.html">Anakia</a>
  35. to render the HTML version from the original XML file.</p>
  36. <p>The Velocity stylesheets used to process the XML files can
  37. be found in the <code>xdocs/stylesheets</code> subdirectory of
  38. Ant&apos;s CVS repository - the build file
  39. <code>docs.xml</code> at the top level of the ant CVS
  40. module is used to drive Anakia.</p>
  41. <p>This file assumes that you have the
  42. <code>jakarta-site2</code> CVS module checked out as well, but
  43. if you follow the instruction from Anakia&apos;s homepage, you
  44. should get it to work without that. Just make sure all
  45. required jars are in the task&apos;s classpath.</p>
  46. </answer>
  47. </faq>
  48. </faqsection>
  49. <faqsection title="General">
  50. <faq id="what-is-ant">
  51. <question>What is Apache Ant?</question>
  52. <answer>
  53. <p> Ant is a Java-based build tool. In theory, it is kind of
  54. like Make, without Make&apos;s wrinkles and with the full
  55. portability of pure Java code.</p>
  56. </answer>
  57. </faq>
  58. <faq id="ant-name">
  59. <question>Why do you call it Ant?</question>
  60. <answer>
  61. <p>According to Ant&apos;s original author, James Duncan
  62. Davidson, the name is an acronym for &quot;Another Neat
  63. Tool&quot;.</p>
  64. <p>Later explanations go along the lines of &quot;ants
  65. do an extremely good job at building things&quot;, or
  66. &quot;ants are very small and can carry a weight dozens of times
  67. their own&quot; - describing what Ant is intended to
  68. be.</p>
  69. </answer>
  70. </faq>
  71. <faq id="history">
  72. <question>Tell us a little bit about Ant&apos;s history.</question>
  73. <answer>
  74. <p>Initially, Ant was part of the Tomcat code base, when it was
  75. donated to the Apache Software Foundation. It was
  76. created by James Duncan Davidson, who is also the original
  77. author of Tomcat. Ant was there to build Tomcat, nothing
  78. else.</p>
  79. <p>Soon thereafter, several open source Java projects realized
  80. that Ant could solve the problems they had with Makefiles.
  81. Starting with the projects hosted at Jakarta and the old Java
  82. Apache project, Ant spread like a virus and is now the build
  83. tool of choice for a lot of projects.</p>
  84. <p>In January 2000, Ant was moved to a separate CVS module and
  85. was promoted to a project of its own, independent of
  86. Tomcat, and became Apache Ant.</p>
  87. <p>The first version of Ant that was exposed to a larger audience
  88. was the one that shipped with Tomcat&apos;s 3.1 release on 19 April
  89. 2000. This version has later been referred to as Ant
  90. 0.3.1.</p>
  91. <p>The first official release of Ant as a stand-alone product was
  92. Ant 1.1, released on 19 July 2000. The complete release
  93. history:</p>
  94. <table>
  95. <tr>
  96. <th>Ant Version</th>
  97. <th>Release Date</th>
  98. </tr>
  99. <tr>
  100. <td>1.1</td>
  101. <td>19 July 2000</td>
  102. </tr>
  103. <tr>
  104. <td>1.2</td>
  105. <td>24 October 2000</td>
  106. </tr>
  107. <tr>
  108. <td>1.3</td>
  109. <td>3 March 2001</td>
  110. </tr>
  111. <tr>
  112. <td>1.4</td>
  113. <td>3 September 2001</td>
  114. </tr>
  115. <tr>
  116. <td>1.4.1</td>
  117. <td>11 October 2001</td>
  118. </tr>
  119. <tr>
  120. <td>1.5</td>
  121. <td>10 July 2002</td>
  122. </tr>
  123. <tr>
  124. <td>1.5.1</td>
  125. <td>3 October 2002</td>
  126. </tr>
  127. <tr>
  128. <td>1.5.2</td>
  129. <td>3 March 2003</td>
  130. </tr>
  131. <tr>
  132. <td>1.5.3</td>
  133. <td>9 April 2003</td>
  134. </tr>
  135. <tr>
  136. <td>1.5.4</td>
  137. <td>12 August 2003</td>
  138. </tr>
  139. <tr>
  140. <td>1.6.0</td>
  141. <td>18 December 2003</td>
  142. </tr>
  143. </table>
  144. </answer>
  145. </faq>
  146. </faqsection>
  147. <faqsection title="Installation">
  148. <faq id="no-gnu-tar">
  149. <question>I get checksum errors when I try to extract the
  150. <code>tar.gz</code> distribution file. Why?</question>
  151. <answer>
  152. <p>Ant&apos;s distribution contains file names that are longer
  153. than 100 characters, which is not supported by the standard
  154. tar file format. Several different implementations of tar use
  155. different and incompatible ways to work around this
  156. restriction.</p>
  157. <p>Ant&apos;s &lt;tar&gt; task can create tar archives that use
  158. the GNU tar extension, and this has been used when putting
  159. together the distribution. If you are using a different
  160. version of tar (for example, the one shipping with Solaris),
  161. you cannot use it to extract the archive.</p>
  162. <p>The solution is to either install GNU tar, which can be
  163. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>,
  164. or use the zip archive instead (you can extract it using
  165. <code>jar xf</code>).</p>
  166. </answer>
  167. </faq>
  168. </faqsection>
  169. <faqsection title="How do I ...">
  170. <faq id="adding-external-tasks">
  171. <question>How do I add an external task that I&apos;ve written to the
  172. page &quot;External Tools and Task&quot;?</question>
  173. <answer>
  174. <p>Join and post a message to the dev or user mailing
  175. list (one list is enough), including the following
  176. information:</p>
  177. <ul>
  178. <li>the name of the task/tool</li>
  179. <li>a short description of the task/tool</li>
  180. <li>a Compatibility: entry stating with which version(s) of
  181. Ant the tool/task is compatible to</li>
  182. <li>a URL: entry linking to the main page of the tool/task</li>
  183. <li>a Contact: entry containing the email address or the URL
  184. of a webpage for the person or list to contact for issues
  185. related to the tool/task. <strong>Note that we&apos;ll add a
  186. link on the page, so any email address added there is not
  187. obfuscated and can (and probably will) be abused by robots
  188. harvesting websites for addresses to spam.</strong></li>
  189. <li>a License: entry containing the type of license for the
  190. tool/task</li>
  191. </ul>
  192. <p>The preferred format for this information is a patch to <a
  193. href="http://cvs.apache.org/viewcvs.cgi/~checkout~/ant/xdocs/external.xml">this</a>
  194. document.</p>
  195. </answer>
  196. </faq>
  197. <faq id="passing-cli-args">
  198. <question>How do I pass parameters from the command line to my
  199. build file?</question>
  200. <answer>
  201. <p>Use properties. Using <code>ant
  202. -D<em>name</em>=<em>value</em></code> lets you define values for
  203. properties on the Ant command line. These properties can then be
  204. used within your build file as
  205. any normal property: <code>${<em>name</em>}</code> will put in
  206. <code><em>value</em></code>.</p>
  207. </answer>
  208. </faq>
  209. <faq id="jikes-switches">
  210. <question>How can I use Jikes-specific command-line
  211. switches?</question>
  212. <answer>
  213. <p>A couple of switches are supported via &quot;magic&quot;
  214. properties:</p>
  215. <table>
  216. <tr>
  217. <th>switch</th>
  218. <th>property</th>
  219. <th>default</th>
  220. </tr>
  221. <tr>
  222. <td>+E</td>
  223. <td>build.compiler.emacs</td>
  224. <td>false == not set</td>
  225. </tr>
  226. <tr>
  227. <td>+P</td>
  228. <td>build.compiler.pedantic</td>
  229. <td>false == not set</td>
  230. </tr>
  231. <tr>
  232. <td>+F</td>
  233. <td>build.compiler.fulldepend</td>
  234. <td>false == not set</td>
  235. </tr>
  236. <tr>
  237. <td><strong>(Only for Ant &lt; 1.4; replaced by the
  238. <code><strong>nowarn</strong></code>
  239. attribute of the <code><strong>&lt;javac&gt;</strong></code>
  240. task after that.)</strong><br></br>-nowarn</td>
  241. <td>build.compiler.warnings</td>
  242. <td>true == not set</td>
  243. </tr>
  244. </table>
  245. <p>With Ant &gt;= 1.5, you can also use nested
  246. <code>&lt;compilerarg&gt;</code> elements with the
  247. <code>&lt;javac&gt;</code> task.</p>
  248. </answer>
  249. </faq>
  250. <faq id="shell-redirect-1">
  251. <question>How do I include a &lt; character in my command-line arguments?</question>
  252. <answer>
  253. <p>The short answer is "Use: <code>&amp;lt;</code>".</p>
  254. <p>The long answer is that this probably won&apos;t do what you
  255. want anyway (see <a href="#shell-redirect-2">the next
  256. section</a>).</p>
  257. </answer>
  258. </faq>
  259. <faq id="shell-redirect-2">
  260. <question>How do I redirect standard input or standard output
  261. in the <code>&lt;exec&gt;</code> task?</question>
  262. <answer>
  263. <p>Say you want to redirect the standard output stream of the
  264. <code>m4</code> command to write to a file, something
  265. like:</p>
  266. <source><![CDATA[
  267. shell-prompt> m4 foo.m4 > foo
  268. ]]></source>
  269. <p>and try to translate it into</p>
  270. <source><![CDATA[
  271. <exec executable="m4">
  272. <arg value="foo.m4"/>
  273. <arg value="&gt;"/>
  274. <arg value="foo"/>
  275. </exec>
  276. ]]></source>
  277. <p>This will not do what you expect. The output redirection is
  278. performed by your shell, not the command itself, so this
  279. should read:</p>
  280. <source><![CDATA[
  281. <exec executable="/bin/sh">
  282. <arg value="-c" />
  283. <arg value="m4 foo.m4 &gt; foo" />
  284. </exec>
  285. ]]></source>
  286. <p>Note that you must use the <code>value</code> attribute of
  287. <code>&lt;arg&gt;</code> in the last element, in order to have
  288. the command passed as a single, quoted argument. Alternatively,
  289. you can use:</p>
  290. <source><![CDATA[
  291. <exec executable="/bin/sh">
  292. <arg line='-c "m4 foo.m4 &gt; foo"'/>
  293. </exec>
  294. ]]></source>
  295. <p>Note the double-quotes nested inside the single-quotes.</p>
  296. </answer>
  297. </faq>
  298. <faq id="batch-shell-execute">
  299. <question>How do I execute a batch file or shell script from Ant?</question>
  300. <answer>
  301. <p>On native Unix systems, you should be able to run shell scripts
  302. directly. On systems running a Unix-type shell (for example, Cygwin
  303. on Windows) execute the (command) shell instead - <code>cmd</code>
  304. for batch files, <code>sh</code> for shell scripts - then pass the
  305. batch file or shell script (plus any arguments to the script)
  306. as a single command, using the <code>/c</code> or
  307. <code>-c</code> switch, respectively. See
  308. <a href="#shell-redirect-2">the above section</a>
  309. for example <code>&lt;exec&gt;</code> tasks
  310. executing <code>sh</code>. For batch files, use something like:</p>
  311. <source><![CDATA[
  312. <exec dir="." executable="cmd" os="Windows NT">
  313. <arg line="/c test.bat"/>
  314. </exec>
  315. ]]></source>
  316. </answer>
  317. </faq>
  318. <faq id="multi-conditions">
  319. <question>I want to execute a particular target only if
  320. multiple conditions are true.</question>
  321. <answer>
  322. <p>There are actually several answers to this question.</p>
  323. <p>If you have only one set and one unset property to test,
  324. you can specify both an <code>if</code> and an <code>unless</code>
  325. attribute for the target, and they will act as if they
  326. are &quot;anded&quot; together.</p>
  327. <p>If you are using a version of Ant 1.3 or earlier, the
  328. way to work with all other cases is to chain targets together
  329. to determine the specific state you want to test for.</p>
  330. <p>To see how this works, assume you have three properties:
  331. <code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
  332. You want to test that <code>prop1</code> and <code>prop2</code>
  333. are set, and that <code>prop3</code> is not. If the condition
  334. holds true you want to echo &quot;yes&quot;.</p>
  335. <p>Here is the implementation in Ant 1.3 and earlier:</p>
  336. <source><![CDATA[
  337. <target name="cond" depends="cond-if"/>
  338. <target name="cond-if" if="prop1">
  339. <antcall target="cond-if-2"/>
  340. </target>
  341. <target name="cond-if-2" if="prop2">
  342. <antcall target="cond-if-3"/>
  343. </target>
  344. <target name="cond-if-3" unless="prop3">
  345. <echo message="yes"/>
  346. </target>
  347. ]]></source>
  348. <p>Note: <code>&lt;antcall&gt;</code> tasks do <em>not</em> pass
  349. property changes back up to the environment they were called
  350. from, so you would&apos;nt be able to, for example, set a
  351. <code>result</code> property in the <code>cond-if-3</code> target,
  352. then do
  353. <code>&lt;echo message=&quot;result is ${result}&quot;/&gt;</code>
  354. in the <code>cond</code> target.</p>
  355. <p>Starting with Ant 1.4, you can use the
  356. <code>&lt;condition&gt;</code> task.</p>
  357. <source><![CDATA[
  358. <target name="cond" depends="cond-if,cond-else"/>
  359. <target name="check-cond">
  360. <condition property="cond-is-true">
  361. <and>
  362. <not>
  363. <equals arg1="${prop1}" arg2="$${prop1}" />
  364. </not>
  365. <not>
  366. <equals arg1="${prop2}" arg2="$${prop2}" />
  367. </not>
  368. <equals arg1="${prop3}" arg2="$${prop3}" />
  369. </and>
  370. </condition>
  371. </target>
  372. <target name="cond-if" depends="check-cond" if="cond-is-true">
  373. <echo message="yes"/>
  374. </target>
  375. <target name="cond-else" depends="check-cond" unless="cond-is-true">
  376. <echo message="no"/>
  377. </target>
  378. ]]></source>
  379. <p>This version takes advantage of two things:</p>
  380. <ul>
  381. <li>If a property <code>a</code> has not been set,
  382. <code>${a}</code> will evaluate to <code>${a}</code>.</li>
  383. <li>To get a literal <code>$</code> in Ant, you have to
  384. escape it with another <code>$</code> - this will also break
  385. the special treatment of the <code>${</code> sequence.</li>
  386. </ul>
  387. <p>Because testing for a literal <code>${property}</code> string
  388. isn&apos;t all that readable or easy to understand,
  389. post-1.4.1 Ant introduces the <code>&lt;isset&gt;</code> element
  390. to the <code>&lt;condition&gt;</code> task.</p>
  391. <p>Here is the previous example done using
  392. <code>&lt;isset&gt;</code>:</p>
  393. <source><![CDATA[
  394. <target name="check-cond">
  395. <condition property="cond-is-true">
  396. <and>
  397. <isset property="prop1"/>
  398. <isset property="prop2"/>
  399. <not>
  400. <isset property="prop3"/>
  401. </not>
  402. </and>
  403. </condition>
  404. </target>
  405. ]]></source>
  406. <p>The last option is to use a scripting language to set the
  407. properties. This can be particularly handy when you need much
  408. finer control than the simple conditions shown here but, of
  409. course, comes with the overhead of adding JAR files to support
  410. the language, to say nothing of the added maintenance in requiring
  411. two languages to implement a single system. See the
  412. <a href="manual/OptionalTasks/script.html">
  413. <code>&lt;script&gt;</code> task documentation</a> for more
  414. details.</p>
  415. </answer>
  416. </faq>
  417. <faq id="encoding">
  418. <question>How can I include national characters like German
  419. umlauts in my build file?</question>
  420. <answer>
  421. <p>You need to tell the XML parser which character encoding
  422. your build file uses, this is done inside the <a
  423. href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd">XML
  424. declaration</a>.</p>
  425. <p>By default the parser assumes you are using the UTF-8
  426. encoding instead of your platform&apos;s default. For most Western
  427. European countries you should set the encoding to
  428. <code>ISO-8859-1</code>. To do so, make the very first line
  429. of you build file read like</p>
  430. <source><![CDATA[
  431. <?xml version="1.0" encoding="ISO-8859-1" ?>
  432. ]]></source>
  433. </answer>
  434. </faq>
  435. <faq id="use-zip-instead-of-jar">
  436. <question>How do I use <code>jar</code>&apos;s <code>M</code> switch?
  437. I don&apos;t want a MANIFEST.</question>
  438. <answer>
  439. <p>A JAR archive is a ZIP file, so if you don&apos;t want a
  440. MANIFEST you can simply use <code>&lt;zip&gt;</code>.</p>
  441. <p>If your file names contain national characters you should
  442. know that Sun&apos;s <code>jar</code> utility like Ant&apos;s
  443. <code>&lt;jar&gt;</code> uses UFT8 to encode their names while
  444. <code>&lt;zip&gt;</code> uses your platforms default encoding.
  445. Use the encoding attribute of <code>&lt;zip&gt;</code> if
  446. necessary.</p>
  447. </answer>
  448. </faq>
  449. <faq id="propertyvalue-as-name-for-property">
  450. <question>How can I do something like <code>&lt;property name="prop"
  451. value="${${anotherprop}}"/&gt;</code> (double expanding the property)?</question>
  452. <answer>
  453. <p>Without any external help you can not.</p>
  454. <p>With &lt;script/&gt;, which needs external libraries, you can do</p>
  455. <source><![CDATA[
  456. <script language="javascript">
  457. propname = project.getProperty("anotherprop");
  458. project.setNewProperty("prop", propname);
  459. </script>
  460. ]]></source>
  461. <p>With AntContrib (external task library) you can do <code>
  462. &lt;propertycopy name="prop" from="${anotherprop}"/&gt;</code>.</p>
  463. </answer>
  464. </faq>
  465. </faqsection>
  466. <faqsection title="It doesn&apos;t work (as expected)">
  467. <faq id="always-recompiles">
  468. <question>Why does Ant always recompile all my Java files?</question>
  469. <answer>
  470. <p>In order to find out which files should be compiled, Ant
  471. compares the timestamps of the source files to those of the
  472. resulting <code>.class</code> files. Opening all source files
  473. to find out which package they belong to would be very
  474. inefficient. Instead, Ant expects you to place your
  475. source files in a directory hierarchy that mirrors your
  476. package hierarchy and to point Ant to the root of this
  477. directory tree with the <code>srcdir</code> attribute.</p>
  478. <p>Say you have <code>&lt;javac srcdir=&quot;src&quot;
  479. destdir=&quot;dest&quot;/&gt;</code>. If Ant finds a file
  480. <code>src/a/b/C.java</code>, it expects it to be in package
  481. <code>a.b</code> so that the resulting <code>.class</code>
  482. file is going to be <code>dest/a/b/C.class</code>.</p>
  483. <p>If your source-tree directory structure does not match your
  484. package structure, Ant&apos;s heuristic won&apos;t work, and
  485. it will recompile classes that are up-to-date. Ant is not the
  486. only tool that expects a source-tree layout like this.</p>
  487. <p>If you have Java source files that aren&apos;t declared to
  488. be part of any package, you can still use the <code>&lt;javac&gt;</code>
  489. task to compile these files correctly - just set the
  490. <code>srcdir</code> and <code>destdir</code> attributes to
  491. the actual directory the source
  492. files live in and the directory the class files should go into,
  493. respectively.</p>
  494. </answer>
  495. </faq>
  496. <faq id="defaultexcludes">
  497. <question>I&apos;ve used a <code>&lt;delete&gt;</code> task to
  498. delete unwanted SourceSafe control files (CVS files, editor
  499. backup files, etc.), but it doesn&apos;t seem to work; the files
  500. never get deleted. What&apos;s wrong?</question>
  501. <answer>
  502. <p>This is probably happening because, by default, Ant excludes
  503. SourceSafe control files (<code>vssver.scc</code>) and certain other
  504. files from FileSets.</p>
  505. <p>Here&apos;s what you probably did:</p>
  506. <source><![CDATA[
  507. <delete>
  508. <fileset dir="${build.src}" includes="**/vssver.scc"/>
  509. </delete>
  510. ]]></source>
  511. <p>You need to switch off the default exclusions,
  512. and it will work:</p>
  513. <source><![CDATA[
  514. <delete>
  515. <fileset dir="${build.src}" includes="**/vssver.scc"
  516. defaultexcludes="no"/>
  517. </delete>
  518. ]]></source>
  519. <p>For a complete listing of the patterns that are excluded
  520. by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
  521. manual</a>.</p>
  522. </answer>
  523. </faq>
  524. <faq id="stop-dependency">
  525. <question>I have a target I want to skip if a property is set,
  526. so I have <code>unless=&quot;property&quot;</code> as an attribute
  527. of the target, but all the targets this target
  528. depends on are still executed. Why?</question>
  529. <answer>
  530. <p>The list of dependencies is generated by Ant before any of the
  531. targets are run. This allows dependent targets, such as an
  532. <code>init</code> target, to set properties that can control the
  533. execution of the targets higher in the dependency graph. This
  534. is a good thing.</p>
  535. <p>However, when your dependencies break down the
  536. higher-level task
  537. into several smaller steps, this behaviour becomes
  538. counter-intuitive. There are a couple of solutions available:
  539. </p>
  540. <ol>
  541. <li>Put the same condition on each of the dependent targets.</li>
  542. <li>Execute the steps using <code>&lt;antcall&gt;</code>,
  543. instead of specifying them inside the <code>depends</code>
  544. attribute.</li>
  545. </ol>
  546. </answer>
  547. </faq>
  548. <faq id="include-order">
  549. <question>In my <code>&lt;fileset&gt;</code>, I&apos;ve put in an
  550. <code>&lt;exclude&gt;</code> of all files followed by an
  551. <code>&lt;include&gt;</code> of just the files I want, but it
  552. isn&apos;t giving me any files at all. What&apos;s wrong?
  553. </question>
  554. <answer>
  555. <p>The order of the <code>&lt;include&gt;</code> and
  556. <code>&lt;exclude&gt;</code> tags within a <code>&lt;fileset&gt;</code>
  557. is ignored when the FileSet is created. Instead, all of the
  558. <code>&lt;include&gt;</code> elements are processed together,
  559. followed by all of the <code>&lt;exclude&gt;</code>
  560. elements. This means that the <code>&lt;exclude&gt;</code>
  561. elements only apply to the file list produced by the
  562. <code>&lt;include&gt;</code> elements.</p>
  563. <p>To get the files you want, focus on just the
  564. <code>&lt;include&gt;</code> patterns that would be necessary
  565. to get them. If you find you need to trim the list that the
  566. <code>&lt;include&gt;</code> elements produce, then use
  567. <code>&lt;exclude&gt;</code> elements.</p>
  568. </answer>
  569. </faq>
  570. <faq id="properties-not-trimmed">
  571. <question><code>ant</code> failed to build my program via javac
  572. even when I put the needed jars in an external
  573. <code>build.properties</code> file and reference them by
  574. <code>pathelement</code> or <code>classpath refid</code>.</question>
  575. <answer>
  576. <p>When <code>ant</code> loads properties from an external
  577. file it dosn&apos;t touch the value of properties, trailing blanks
  578. will not be trimmed for example.</p>
  579. <p>If the value represents a file path, like a jar needed to
  580. compile, the task which requires the value, javac for example
  581. would fail to compile since it can&apos;t find the file due to
  582. trailing spaces.</p>
  583. </answer>
  584. </faq>
  585. <faq id="winzip-lies">
  586. <question>Ant creates WAR files with a lower-case
  587. <code>web-inf</code> or JAR files with a lower-case
  588. <code>meta-inf</code> directory.</question>
  589. <answer>
  590. <p>No it doesn&apos;t.</p>
  591. <p>You may have seen these lower-case directory names in
  592. WinZIP, but WinZIP is trying to be helpful (and fails). If
  593. WinZIP encounters a filename that is all upper-case, it
  594. assumes it has come from an old DOS box and changes the case to
  595. all lower-case for you.</p>
  596. <p>If you extract (or just check) the archive with jar, you
  597. will see that the names have the correct case.</p>
  598. <p>With WinZIP (version 8.1 at least), this can be corrected in the
  599. configuration. In the Options/Configuration menu, in the View tab, General
  600. section, check the "Allow all upper case files names" box. The META-INF and
  601. WEB-INF will look correct.</p>
  602. </answer>
  603. </faq>
  604. </faqsection>
  605. <faqsection title="Ant and IDEs/Editors">
  606. <faq id="integration">
  607. <question>Is Ant supported by my IDE/Editor?</question>
  608. <answer>
  609. <p>See the <a href="external.html#IDE and Editor Integration">section
  610. on IDE integration</a> on our External Tools and Tasks page.</p>
  611. </answer>
  612. </faq>
  613. <faq id="emacs-mode">
  614. <question>Why doesn&apos;t (X)Emacs/vi/MacOS X&apos;s project builder
  615. correctly parse the error messages generated by Ant?</question>
  616. <answer>
  617. <p>Ant adds a &quot;banner&quot; with the name of the current
  618. task in front of all logging messages - and there are no built-in
  619. regular expressions in your editor that would account for
  620. this.</p>
  621. <p>You can disable this banner by invoking Ant with the
  622. <code>-emacs</code> switch. To make Ant autodetect
  623. Emacs&apos; compile mode, put this into your
  624. <code>.antrc</code> (contributed by Ville Skytt&#228;).</p>
  625. <source><![CDATA[
  626. # Detect (X)Emacs compile mode
  627. if [ "$EMACS" = "t" ] ; then
  628. ANT_ARGS="$ANT_ARGS -emacs"
  629. ANT_OPTS="$ANT_OPTS -Dbuild.compiler.emacs=true"
  630. fi
  631. ]]></source>
  632. <p>Alternatively, you can add the following snippet to your
  633. <code>.emacs</code> to make Emacs understand Ant&apos;s
  634. output.</p>
  635. <source><![CDATA[
  636. (require 'compile)
  637. (setq compilation-error-regexp-alist
  638. (append (list
  639. ;; works for jikes
  640. '("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:" 1 2 3)
  641. ;; works for javac
  642. '("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):" 1 2))
  643. compilation-error-regexp-alist))
  644. ]]></source>
  645. <p>Yet another alternative that preserves most of Ant&apos;s
  646. formatting is to pipe Ant&apos;s output through the following Perl
  647. script by Dirk-Willem van Gulik:</p>
  648. <source><![CDATA[
  649. #!/usr/bin/perl
  650. #
  651. # May 2001 dirkx@apache.org - remove any
  652. # [foo] lines from the output; keeping
  653. # spacing more or less there.
  654. #
  655. $|=1;
  656. while(<STDIN>) {
  657. if (s/^(\s+)\[(\w+)\]//) {
  658. if ($2 ne $last) {
  659. print "$1\[$2\]";
  660. $s = ' ' x length($2);
  661. } else {
  662. print "$1 $s ";
  663. };
  664. $last = $2;
  665. };
  666. print;
  667. };
  668. ]]></source>
  669. </answer>
  670. </faq>
  671. </faqsection>
  672. <faqsection title="Advanced Issues">
  673. <faq id="dtd">
  674. <question>Is there a DTD that I can use to validate my build
  675. files?</question>
  676. <answer>
  677. <p>An incomplete DTD can be created by the
  678. <code>&lt;antstructure&gt;</code> task - but this one
  679. has a few problems:</p>
  680. <ul>
  681. <li>It doesn&apos;t know about required attributes. Only
  682. manual tweaking of this file can help here.</li>
  683. <li>It is not complete - if you add new tasks via
  684. <code>&lt;taskdef&gt;</code> it won&apos;t know about it. See
  685. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  686. page</a> by Michel Casabianca for a solution to this
  687. problem. Note that the DTD you can download at this page
  688. is based on Ant 0.3.1.</li>
  689. <li>It may even be an invalid DTD. As Ant allows tasks
  690. writers to define arbitrary elements, name collisions will
  691. happen quite frequently - if your version of Ant contains
  692. the optional <code>&lt;test&gt;</code> and
  693. <code>&lt;junit&gt;</code> tasks, there are two XML
  694. elements named <code>test</code> (the task and the nested child
  695. element of <code>&lt;junit&gt;</code>) with different attribute
  696. lists. This problem cannot be solved; DTDs don&apos;t give a
  697. syntax rich enough to support this.</li>
  698. </ul>
  699. </answer>
  700. </faq>
  701. <faq id="xml-entity-include">
  702. <question>How do I include an XML snippet in my build file?</question>
  703. <answer>
  704. <p>You can use XML&apos;s way of including external files and let
  705. the parser do the job for Ant:</p>
  706. <source><![CDATA[
  707. <?xml version="1.0"?>
  708. <!DOCTYPE project [
  709. <!ENTITY common SYSTEM "file:./common.xml">
  710. ]>
  711. <project name="test" default="test" basedir=".">
  712. <target name="setup">
  713. ...
  714. </target>
  715. &common;
  716. ...
  717. </project>
  718. ]]></source>
  719. <p>will literally include the contents of <code>common.xml</code> where
  720. you&apos;ve placed the <code>&amp;common;</code> entity.</p>
  721. <p>In combination with a DTD, this would look like this:</p>
  722. <source><![CDATA[
  723. <!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "file:./ant.dtd" [
  724. <!ENTITY include SYSTEM "file:./header.xml">
  725. ]>
  726. ]]></source>
  727. <p>Starting with Ant 1.6, there is a new
  728. <code>&lt;import&gt;</code> task that can (also) be used to
  729. include build file fragments. Unlike the snippets used with
  730. entity includes, the referenced files have to be complete Ant
  731. build files, though.</p>
  732. <p>The example above would become:</p>
  733. <source><![CDATA[
  734. <?xml version="1.0"?>
  735. <project name="test" default="test" basedir=".">
  736. <target name="setup">
  737. ...
  738. </target>
  739. <import file="../common.xml"/>
  740. ...
  741. </project>
  742. ]]></source>
  743. <p>Unlike entity includes, <code>&lt;import&gt;</code> will
  744. let you use Ant properties in the file name.</p>
  745. </answer>
  746. </faq>
  747. <faq id="mail-logger">
  748. <question>How do I send an email with the result of my build
  749. process?</question>
  750. <answer>
  751. <p>If you are using a nightly build of Ant 1.5 after
  752. 2001-12-14, you can use the built-in MailLogger:</p>
  753. <source><![CDATA[
  754. ant -logger org.apache.tools.ant.listener.MailLogger
  755. ]]></source>
  756. <p>See the <a href="http://cvs.apache.org/viewcvs/~checkout~/ant/docs/manual/listeners.html?content-type=text/html">Listeners
  757. &amp; Loggers</a> documentation for details on the properties
  758. required.</p>
  759. <p>For older versions of Ant, you can use a custom
  760. BuildListener that sends out an email
  761. in the buildFinished() method. Will Glozer
  762. &lt;will.glozer@jda.com&gt; has written such a listener based
  763. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
  764. The source is:</p>
  765. <source><![CDATA[
  766. import java.io.*;
  767. import java.util.*;
  768. import javax.mail.*;
  769. import javax.mail.internet.*;
  770. import org.apache.tools.ant.*;
  771. /**
  772. * A simple listener that waits for a build to finish and sends an email
  773. * of the results. The settings are stored in "monitor.properties" and
  774. * are fairly self explanatory.
  775. *
  776. * @author Will Glozer
  777. * @version 1.05a 09/06/2000
  778. */
  779. public class BuildMonitor implements BuildListener {
  780. protected Properties props;
  781. /**
  782. * Create a new BuildMonitor.
  783. */
  784. public BuildMonitor() throws Exception {
  785. props = new Properties();
  786. InputStream is = getClass().getResourceAsStream("monitor.properties");
  787. props.load(is);
  788. is.close();
  789. }
  790. public void buildStarted(BuildEvent e) {
  791. }
  792. /**
  793. * Determine the status of the build and the actions to follow, now that
  794. * the build has completed.
  795. *
  796. * @param e Event describing the build status.
  797. */
  798. public void buildFinished(BuildEvent e) {
  799. Throwable th = e.getException();
  800. String status = (th != null) ? "failed" : "succeeded";
  801. try {
  802. String key = "build." + status;
  803. if (props.getProperty(key + ".notify").equalsIgnoreCase("false")) {
  804. return;
  805. }
  806. Session session = Session.getDefaultInstance(props, null);
  807. MimeMessage message = new MimeMessage(session);
  808. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  809. props.getProperty(key + ".email.to")));
  810. message.setSubject(props.getProperty(key + ".email.subject"));
  811. BufferedReader br = new BufferedReader(new FileReader(
  812. props.getProperty("build.log")));
  813. StringWriter sw = new StringWriter();
  814. String line = br.readLine();
  815. while (line != null) {
  816. sw.write(line);
  817. sw.write("\n");
  818. line = br.readLine();
  819. }
  820. br.close();
  821. message.setText(sw.toString(), "UTF-8");
  822. sw.close();
  823. Transport transport = session.getTransport();
  824. transport.connect();
  825. transport.send(message);
  826. transport.close();
  827. } catch (Exception ex) {
  828. System.out.println("BuildMonitor failed to send email!");
  829. ex.printStackTrace();
  830. }
  831. }
  832. /**
  833. * Parse a comma separated list of internet email addresses.
  834. *
  835. * @param s The list of addresses.
  836. * @return Array of Addresses.
  837. */
  838. protected Address[] parseAddresses(String s) throws Exception {
  839. StringTokenizer st = new StringTokenizer(s, ",");
  840. Address[] addrs = new Address[st.countTokens()];
  841. for (int i = 0; i < addrs.length; i++) {
  842. addrs[i] = new InternetAddress(st.nextToken());
  843. }
  844. return addrs;
  845. }
  846. public void messageLogged(BuildEvent e) {
  847. }
  848. public void targetStarted(BuildEvent e) {
  849. }
  850. public void targetFinished(BuildEvent e) {
  851. }
  852. public void taskStarted(BuildEvent e) {
  853. }
  854. public void taskFinished(BuildEvent e) {
  855. }
  856. }
  857. ]]></source>
  858. <p>With a <code>monitor.properties</code> like this:</p>
  859. <source><![CDATA[
  860. # configuration for build monitor
  861. mail.transport.protocol=smtp
  862. mail.smtp.host=<host>
  863. mail.from=Will Glozer <will.glozer@jda.com>
  864. build.log=build.log
  865. build.failed.notify=true
  866. build.failed.email.to=will.glozer@jda.com
  867. build.failed.email.subject=Nightly build failed!
  868. build.succeeded.notify=true
  869. build.succeeded.email.to=will.glozer@jda.com
  870. build.succeeded.email.subject=Nightly build succeeded!
  871. ]]></source>
  872. <p><code>monitor.properties</code> should be placed right next
  873. to your compiled <code>BuildMonitor.class</code>. To use it,
  874. invoke Ant like:</p>
  875. <source><![CDATA[
  876. ant -listener BuildMonitor -logfile build.log
  877. ]]></source>
  878. <p>Make sure that <code>mail.jar</code> from JavaMail and
  879. <code>activation.jar</code> from the
  880. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  881. Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
  882. </answer>
  883. </faq>
  884. <faq id="listener-properties">
  885. <question>How do I get at the properties that Ant was running
  886. with from inside BuildListener?</question>
  887. <answer>
  888. <p>You can get at a hashtable with all the properties that Ant
  889. has been using through the BuildEvent parameter. For
  890. example:</p>
  891. <source><![CDATA[
  892. public void buildFinished(BuildEvent e) {
  893. Hashtable table = e.getProject().getProperties();
  894. String buildpath = (String)table.get("build.path");
  895. ...
  896. }
  897. ]]></source>
  898. <p>This is more accurate than just reading the same property
  899. files that your project does, since it will give the correct
  900. results for properties that were specified on the Ant command line.</p>
  901. </answer>
  902. </faq>
  903. </faqsection>
  904. <faqsection title="Known Problems">
  905. <faq id="remove-cr">
  906. <question>&lt;chmod&gt; or &lt;exec&gt; doesn&apos;t work in Ant
  907. 1.3 on Unix</question>
  908. <answer>
  909. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  910. has DOS instead of Unix line endings; you must remove the
  911. carriage-return characters from this file. This can be done by
  912. using Ant&apos;s <code>&lt;fixcrlf&gt;</code> task
  913. or something like:</p>
  914. <source><![CDATA[
  915. tr -d '\r' < $ANT_HOME/bin/antRun > /tmp/foo
  916. mv /tmp/foo $ANT_HOME/bin/antRun
  917. ]]></source>
  918. </answer>
  919. </faq>
  920. <faq id="javadoc-cannot-execute">
  921. <question>JavaDoc failed: java.io.IOException: javadoc: cannot execute</question>
  922. <answer>
  923. <p>There is a bug in the Solaris reference implementation of
  924. the JDK (see <a href="http://developer.java.sun.com/developer/bugParade/bugs/4230399.html">http://developer.java.sun.com/developer/bugParade/bugs/4230399.html</a>).
  925. This also appears to be true under Linux. Moving the JDK to
  926. the front of the PATH fixes the problem.</p>
  927. </answer>
  928. </faq>
  929. <faq id="delegating-classloader">
  930. <question>&lt;style&gt; or &lt;junit&gt; ignores my
  931. &lt;classpath&gt;</question>
  932. <answer>
  933. <p>These tasks don&apos;t ignore your classpath setting, you
  934. are facing a common problem with delegating classloaders.</p>
  935. <p>First of all let&apos;s state that Ant adds all
  936. <code>.jar</code> files from <code>ANT_HOME/lib</code> to
  937. <code>CLASSPATH</code>, therefore &quot;in
  938. <code>CLASSPATH</code>&quot; shall mean &quot;either in your
  939. <code>CLASSPATH</code> environment variable or
  940. <code>ANT_HOME/lib</code>&quot; for the rest of this
  941. answer.</p>
  942. <p>Technically the sentence above isn&apos;t true for Ant 1.6
  943. and later anymore, but the result is the same. For the sake
  944. of this discussion, <code>CLASSPATH</code> and
  945. <code>ANT_HOME/lib</code> are identical.</p>
  946. <p>This question collects a common type of problem: A task
  947. needs an external library and it has a nested classpath
  948. element so that you can point it to this external library, but
  949. that doesn&apos;t work unless you put the external library into the
  950. <code>CLASSPATH</code>.</p>
  951. <p>The root of the problem is that the class that needs the
  952. external library is on the <code>CLASSPATH</code>.</p>
  953. <p>When you specify a nested <code>&lt;classpath&gt;</code> in
  954. Ant, Ant creates a new class loader that uses the path you
  955. have specified. It then tries to load additional classes from
  956. this classloader.</p>
  957. <p>In most cases - for example the two cases above - Ant
  958. doesn&apos;t load the external library directly, it is the loaded
  959. class that does so.</p>
  960. <p>In the case of <code>&lt;junit&gt;</code> it is the task
  961. implementation itself and in the case of
  962. <code>&lt;style&gt;</code> it is the implementation of the
  963. <code>org.apache.tools.ant.taskdefs.XSLTLiaison</code>
  964. class.</p>
  965. <p>Ant&apos;s class loader implementation uses Java&apos;s
  966. delegation model, see <a
  967. href="http://java.sun.com/products/jdk/1.2/docs/api/java/lang/ClassLoader.html">http://java.sun.com/products/jdk/1.2/docs/api/java/lang/ClassLoader.html</a>
  968. the paragraph</p>
  969. <blockquote>The <code>ClassLoader</code> class uses a
  970. delegation model to search for classes and resources. Each
  971. instance of <code>ClassLoader</code> has an associated parent
  972. class loader. When called upon to find a class or resource, a
  973. <code>ClassLoader</code> instance will delegate the search for
  974. the class or resource to its parent class loader before
  975. attempting to find the class or resource itself. The virtual
  976. machine&apos;s built-in class loader, called the bootstrap
  977. class loader, does not itself have a parent but may serve as
  978. the parent of a <code>ClassLoader</code>
  979. instance.</blockquote>
  980. <p>This means, Ant&apos;s class loader will consult the
  981. bootstrap class loader first, which tries to load classes from
  982. <code>CLASSPATH</code>. The bootstrap class loader
  983. doesn&apos;t know anything about Ant&apos;s class loader or
  984. even the path you have specified.</p>
  985. <p>If the bootstrap class loader can load the class Ant has
  986. asked it to load, this class will try to load the external
  987. library from <code>CLASSPATH</code> as well - it doesn&apos;t
  988. know anything else - and will not find it unless the library
  989. is in <code>CLASSPATH</code> as well.</p>
  990. <p>To solve this, you have two major options:</p>
  991. <ol>
  992. <li>put all external libraries you need in
  993. <code>CLASSPATH</code> as well this is not what you want,
  994. otherwise you wouldn&apos;t have found this FAQ entry.</li>
  995. <li>remove the class that loads the external library from
  996. the <code>CLASSPATH</code>.</li>
  997. </ol>
  998. <p><strong>Using The Second Option with Ant 1.5.4 and
  999. Earlier:</strong></p>
  1000. <p>The easiest way to do this is to remove
  1001. <code>optional.jar</code> from <code>ANT_HOME/lib</code>. If
  1002. you do so, you will have to <code>&lt;taskdef&gt;</code> all
  1003. optional tasks and use nested <code>&lt;classpath&gt;</code>
  1004. elements in the <code>&lt;taskdef&gt;</code> tasks that point
  1005. to the new location of <code>optional.jar</code>. Also,
  1006. don&apos;t forget to add the new location of
  1007. <code>optional.jar</code> to the
  1008. <code>&lt;classpath&gt;</code> of your
  1009. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code>
  1010. task.</p>
  1011. <p>If you want to avoid to <code>&lt;taskdef&gt;</code> all
  1012. optional tasks you need, the only other option is to remove
  1013. the classes that should not be loaded via the bootstrap class
  1014. loader from <code>optional.jar</code> and put them into a
  1015. separate archive. Add this separate archive to the
  1016. <code>&lt;classpath&gt;</code> of your
  1017. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code> task
  1018. - and make sure the separate archive is not in
  1019. <code>CLASSPATH</code>.</p>
  1020. <p>In the case of <code>&lt;junit&gt;</code> you&apos;d have
  1021. to remove all classes that are in the
  1022. <code>org/apache/tools/ant/taskdefs/optional/junit</code>
  1023. directory, in the <code>&lt;style&gt;</code> case it is one of
  1024. the <code>*Liaison</code> classes in
  1025. <code>org/apache/tools/ant/taskdefs/optional</code>.</p>
  1026. <p><strong>Using The Second Option with Ant 1.6 and
  1027. later:</strong></p>
  1028. <p>In Ant 1.6 <code>optional.jar</code> has been split into
  1029. multiple jars, each one containing classes with the same
  1030. dependencies on external libraries. You can move the
  1031. "offending" jar out of ANT_HOME/lib. For the
  1032. <code>&lt;junit&gt;</code> task it would be
  1033. <code>ant-junit.jar</code> and for <code>&lt;style&gt;</code>
  1034. it would be <code>ant-trax.jar</code>,
  1035. <code>ant-xalan1.jar</code> or <code>ant-xslp.jar</code> -
  1036. depending on the processor you use.</p>
  1037. <p>If you use the option to break up <code>optional.jar</code>
  1038. for <code>&lt;junit&gt;</code> or remove
  1039. <code>ant-junit.jar</code>, you still have to use a
  1040. <code>&lt;taskdef&gt;</code> with a nested
  1041. <code>&lt;classpath&gt;</code> to define the junit task.</p>
  1042. </answer>
  1043. </faq>
  1044. <faq id="winxp-jdk14-ant14">
  1045. <question>When running Ant 1.4 on Windows XP and JDK 1.4, I get
  1046. various errors when trying to <code>&lt;exec&gt;</code>, fork
  1047. <code>&lt;java&gt;</code> or access environment
  1048. variables.</question>
  1049. <answer>
  1050. <p>Ant &lt; 1.5 doesn&apos;t recognize Windows XP as a flavor
  1051. of Windows that runs <code>CMD.EXE</code> instead of
  1052. <code>COMMAND.COM</code>. JDK 1.3 will tell Ant that Windows
  1053. XP is Windows 2000 so the problem doesn&apos;t show up
  1054. there.</p>
  1055. <p>Apart from upgrading to Ant 1.5 or better, setting the
  1056. environment variable <code>ANT_OPTS</code> to
  1057. <code>-Dos.name=Windows_NT</code> prior to invoking Ant has
  1058. been confirmed as a workaround.</p>
  1059. </answer>
  1060. </faq>
  1061. <faq id="1.5-cygwin-sh">
  1062. <question>The <code>ant</code> wrapper script of Ant 1.5 fails
  1063. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  1064. path.</question>
  1065. <answer>
  1066. <p>This problem has been reported only hours after Ant 1.5 has
  1067. been released, see <a
  1068. href="http://issues.apache.org/bugzilla/show_bug.cgi?id=10664">Bug
  1069. 10664</a> and all its duplicates.</p>
  1070. <p>A fixed version of the wrapper script can be found <a
  1071. href="http://ant.apache.org/old-releases/v1.5/errata/">here</a>.
  1072. Simply replace your script with this version.</p>
  1073. </answer>
  1074. </faq>
  1075. <faq id="1.5.2-zip-broken">
  1076. <question><code>&lt;zip&gt;</code> is broken in Ant 1.5.2.</question>
  1077. <answer>
  1078. <p>Yes, it is.</p>
  1079. <p>The problem reported by most people - see <a
  1080. href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17648">Bug
  1081. 17648</a> and all its duplicates - is that Ant creates
  1082. archives that a partially unreadable by WinZIP. Luckily
  1083. <code>jar</code> deals with the archives and so the generated
  1084. jars/wars/ears will most likely work for you anyway.</p>
  1085. <p>There are additional problems, see bugs <a
  1086. href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17780">Bug
  1087. 17780</a>, <a
  1088. href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17871">Bug
  1089. 17871</a> and <a
  1090. href="http://issues.apache.org/bugzilla/show_bug.cgi?id=18403">Bug
  1091. 18403</a>. All of them are supposed to be fixed with Ant
  1092. 1.5.3 (and only 18403 should exist in 1.5.3beta1).</p>
  1093. </answer>
  1094. </faq>
  1095. </faqsection>
  1096. </document>