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

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