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.html 72 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html lang="en">
  3. <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
  4. <head>
  5. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  6. <title>Apache Ant - Frequently Asked Questions</title>
  7. <link type="text/css" href="./page.css" rel="stylesheet">
  8. <meta name="author" content="Stefan Bodewig">
  9. <meta name="email" content="bodewig@apache.org">
  10. </head>
  11. <body>
  12. <p class="navpath">
  13. <script src="./breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  14. </p>
  15. <div class="logobar">
  16. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  17. <tr>
  18. <td align="left"><img border="0" alt="Apache Ant site" src="./images/group-logo.gif"></td>
  19. <td align="center" width="100%"><img alt="Apache Ant logo" border="0" src="./images/project-logo.gif"></td>
  20. <td align="right">
  21. <form target="_blank" onsubmit="q.value = query.value + ' site:ant.apache.org'" action="http://www.google.com/search" method="get">
  22. <table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
  23. <tr>
  24. <td colspan="3"><img height="10" width="1" alt="" src="./images/spacer.gif"></td>
  25. </tr>
  26. <tr>
  27. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  28. <td nowrap="nowrap" class="searchcaption">
  29. <input name="q" type="hidden">
  30. <input size="15" id="query" type="text">
  31. <img height="1" width="5" alt="" src="./images/spacer.gif">
  32. <input name="Search" value="Search" type="submit">
  33. <br>
  34. the Apache Ant site
  35. </td>
  36. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  37. </tr>
  38. <tr>
  39. <td><img alt="" border="0" height="10" width="9" src="./images/search-left.gif"></td>
  40. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  41. <td><img alt="" border="0" height="10" width="9" src="./images/search-right.gif"></td>
  42. </tr>
  43. </table>
  44. </form>
  45. </td>
  46. </tr>
  47. </table>
  48. </div>
  49. <div class="tab">
  50. <table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
  51. <tr>
  52. <td width="8"><img alt="" height="5" width="8" src="./images/spacer.gif"></td><td valign="bottom">
  53. <table summary="selected tab" style="height: 1.5em" border="0" cellpadding="0" cellspacing="0">
  54. <tr>
  55. <td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="./images/tabSel-left.gif"></td><td valign="middle" bgcolor="#4C6C8F"><font color="#ffffff" size="2" face="Arial, Helvetica, Sans-serif"><b>Home</b></font></td><td valign="top" width="5" bgcolor="#4C6C8F"><img height="5" width="5" alt="" src="./images/tabSel-right.gif"></td>
  56. </tr>
  57. </table>
  58. </td>
  59. <td width="5"><img alt="" height="8" width="8" src="./images/spacer.gif"></td><td valign="bottom">
  60. <table summary="non selected tab" style="height: 1.4em" border="0" cellpadding="0" cellspacing="0">
  61. <tr>
  62. <td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="./images/tab-left.gif"></td><td valign="middle" bgcolor="#B2C4E0"><a href="./projects/index.html"><font size="2" face="Arial, Helvetica, Sans-serif">Projects</font></a></td><td valign="top" width="5" bgcolor="#B2C4E0"><img height="5" width="5" alt="" src="./images/tab-right.gif"></td>
  63. </tr>
  64. </table>
  65. </td>
  66. </tr>
  67. </table>
  68. </div>
  69. <div class="bluebar"></div>
  70. <div class="menucontainer">
  71. <div class="menu">
  72. <ul>
  73. <li class="menuheader">Apache Ant
  74. <ul>
  75. <li>
  76. <a href="./index.html">Welcome</a>
  77. </li>
  78. <li>
  79. <a href="./license.html">License</a>
  80. </li>
  81. <li>
  82. <a href="./antnews.html">News</a>
  83. </li>
  84. </ul>
  85. </li>
  86. <li class="menuheader">Documentation
  87. <ul>
  88. <li>
  89. <a href="./manual/index.html">Manual</a>
  90. </li>
  91. <li>
  92. <a href="./projects.html">Related Projects</a>
  93. </li>
  94. <li>
  95. <a href="./external.html">External Tools and Tasks</a>
  96. </li>
  97. <li>
  98. <a href="./resources.html">Resources</a>
  99. </li>
  100. <li>
  101. <span class="sel">Frequently Asked Questions</span>
  102. </li>
  103. <li>
  104. <a href="http://wiki.apache.org/ant/FrontPage">Wiki</a>
  105. </li>
  106. <li>
  107. <a href="./problems.html">Having Problems?</a>
  108. </li>
  109. </ul>
  110. </li>
  111. <li class="menuheader">Download
  112. <ul>
  113. <li>
  114. <a href="http://ant.apache.org/bindownload.cgi">Binary Distributions</a>
  115. </li>
  116. <li>
  117. <a href="http://ant.apache.org/srcdownload.cgi">Source Distributions</a>
  118. </li>
  119. </ul>
  120. </li>
  121. <li class="menuheader">Contributing
  122. <ul>
  123. <li>
  124. <a href="./mail.html">Mailing Lists</a>
  125. </li>
  126. <li>
  127. <a href="./cvs.html">CVS Repositories</a>
  128. </li>
  129. <li>
  130. <a href="http://issues.apache.org/bugzilla/enter_bug.cgi?product=Ant">Bug Database</a>
  131. </li>
  132. <li>
  133. <a href="http://issues.apache.org/bugzilla/enter_bug.cgi?product=Ant&amp;bug_severity=Enhancement">Enhancement Requests</a>
  134. </li>
  135. <li>
  136. <a href="http://www.apache.org/foundation/contributing.html">Donations</a>
  137. </li>
  138. </ul>
  139. </li>
  140. <li class="menuheader">Project Management
  141. <ul>
  142. <li>
  143. <a href="./contributors.html">Contributors</a>
  144. </li>
  145. <li>
  146. <a href="./mission.html">Apache Ant Mission</a>
  147. </li>
  148. <li>
  149. <a href="./bylaws.html">Project Bylaws</a>
  150. </li>
  151. <li>
  152. <a href="./legal.html">Legal</a>
  153. </li>
  154. </ul>
  155. </li>
  156. </ul>
  157. </div>
  158. <img style="float: left" height="10" width="10" border="0" alt="" src="./images/menu-left.gif">
  159. <img style="float: right" height="10" width="10" border="0" alt="" src="./images/menu-right.gif">
  160. </div>
  161. <div class="lightbluebar">&nbsp;</div>
  162. <div class="main">
  163. <div class="content">
  164. <h1 class="title">Frequently Asked Questions</h1>
  165. <h3 class="section">Questions</h3>
  166. <h4 class="toc">About this FAQ</h4>
  167. <ul>
  168. <li><a href="#latest-version">
  169. Where do I find the latest version of this
  170. document?
  171. </a></li>
  172. <li><a href="#adding-faqs">
  173. How can I contribute to this FAQ?
  174. </a></li>
  175. <li><a href="#creating-faq">
  176. How do you create the HTML version of this
  177. FAQ?
  178. </a></li>
  179. </ul>
  180. <h4 class="toc">General</h4>
  181. <ul>
  182. <li><a href="#what-is-ant">
  183. What is Apache Ant?
  184. </a></li>
  185. <li><a href="#ant-name">
  186. Why do you call it Ant?
  187. </a></li>
  188. <li><a href="#history">
  189. Tell us a little bit about Ant's history.
  190. </a></li>
  191. </ul>
  192. <h4 class="toc">Installation</h4>
  193. <ul>
  194. <li><a href="#no-gnu-tar">
  195. I get checksum errors when I try to extract the
  196. <code>tar.gz</code> distribution file. Why?
  197. </a></li>
  198. </ul>
  199. <h4 class="toc">How do I ...</h4>
  200. <ul>
  201. <li><a href="#adding-external-tasks">
  202. How do I add an external task that I've written to the
  203. page "External Tools and Task"?
  204. </a></li>
  205. <li><a href="#passing-cli-args">
  206. How do I pass parameters from the command line to my
  207. build file?
  208. </a></li>
  209. <li><a href="#jikes-switches">
  210. How can I use Jikes-specific command-line
  211. switches?
  212. </a></li>
  213. <li><a href="#shell-redirect-1">
  214. How do I include a &lt; character in my command-line arguments?
  215. </a></li>
  216. <li><a href="#shell-redirect-2">
  217. How do I redirect standard input or standard output
  218. in the <code>&lt;exec&gt;</code> task?
  219. </a></li>
  220. <li><a href="#batch-shell-execute">
  221. How do I execute a batch file or shell script from Ant?
  222. </a></li>
  223. <li><a href="#multi-conditions">
  224. I want to execute a particular target only if
  225. multiple conditions are true.
  226. </a></li>
  227. <li><a href="#encoding">
  228. How can I include national characters like German
  229. umlauts in my build file?
  230. </a></li>
  231. <li><a href="#use-zip-instead-of-jar">
  232. How do I use <code>jar</code>'s <code>M</code> switch?
  233. I don't want a MANIFEST.
  234. </a></li>
  235. <li><a href="#propertyvalue-as-name-for-property">
  236. How can I do something like <code>&lt;property name="prop"
  237. value="${${anotherprop}}"/&gt;</code> (double expanding the property)?
  238. </a></li>
  239. </ul>
  240. <h4 class="toc">It doesn't work (as expected)</h4>
  241. <ul>
  242. <li><a href="#always-recompiles">
  243. Why does Ant always recompile all my Java files?
  244. </a></li>
  245. <li><a href="#defaultexcludes">
  246. I've used a <code>&lt;delete&gt;</code> task to
  247. delete unwanted SourceSafe control files (CVS files, editor
  248. backup files, etc.), but it doesn't seem to work; the files
  249. never get deleted. What's wrong?
  250. </a></li>
  251. <li><a href="#stop-dependency">
  252. I have a target I want to skip if a property is set,
  253. so I have <code>unless="property"</code> as an attribute
  254. of the target, but all the targets this target
  255. depends on are still executed. Why?
  256. </a></li>
  257. <li><a href="#include-order">
  258. In my <code>&lt;fileset&gt;</code>, I've put in an
  259. <code>&lt;exclude&gt;</code> of all files followed by an
  260. <code>&lt;include&gt;</code> of just the files I want, but it
  261. isn't giving me any files at all. What's wrong?
  262. </a></li>
  263. <li><a href="#properties-not-trimmed">
  264. <code>ant</code> failed to build my program via javac
  265. even when I put the needed jars in an external
  266. <code>build.properties</code> file and reference them by
  267. <code>pathelement</code> or <code>classpath refid</code>.
  268. </a></li>
  269. <li><a href="#winzip-lies">
  270. Ant creates WAR files with a lower-case
  271. <code>web-inf</code> or JAR files with a lower-case
  272. <code>meta-inf</code> directory.
  273. </a></li>
  274. </ul>
  275. <h4 class="toc">Ant and IDEs/Editors</h4>
  276. <ul>
  277. <li><a href="#integration">
  278. Is Ant supported by my IDE/Editor?
  279. </a></li>
  280. <li><a href="#emacs-mode">
  281. Why doesn't (X)Emacs/vi/MacOS X's project builder
  282. correctly parse the error messages generated by Ant?
  283. </a></li>
  284. </ul>
  285. <h4 class="toc">Advanced Issues</h4>
  286. <ul>
  287. <li><a href="#dtd">
  288. Is there a DTD that I can use to validate my build
  289. files?
  290. </a></li>
  291. <li><a href="#xml-entity-include">
  292. How do I include an XML snippet in my build file?
  293. </a></li>
  294. <li><a href="#mail-logger">
  295. How do I send an email with the result of my build
  296. process?
  297. </a></li>
  298. <li><a href="#listener-properties">
  299. How do I get at the properties that Ant was running
  300. with from inside BuildListener?
  301. </a></li>
  302. </ul>
  303. <h4 class="toc">Known Problems</h4>
  304. <ul>
  305. <li><a href="#remove-cr">
  306. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  307. 1.3 on Unix
  308. </a></li>
  309. <li><a href="#javadoc-cannot-execute">
  310. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  311. </a></li>
  312. <li><a href="#delegating-classloader">
  313. &lt;style&gt; or &lt;junit&gt; ignores my
  314. &lt;classpath&gt;
  315. </a></li>
  316. <li><a href="#winxp-jdk14-ant14">
  317. When running Ant 1.4 on Windows XP and JDK 1.4, I get
  318. various errors when trying to <code>&lt;exec&gt;</code>, fork
  319. <code>&lt;java&gt;</code> or access environment
  320. variables.
  321. </a></li>
  322. <li><a href="#1.5-cygwin-sh">
  323. The <code>ant</code> wrapper script of Ant 1.5 fails
  324. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  325. path.
  326. </a></li>
  327. <li><a href="#1.5.2-zip-broken">
  328. <code>&lt;zip&gt;</code> is broken in Ant 1.5.2.
  329. </a></li>
  330. <li><a href="#unknownelement.taskcontainer">
  331. Why do my custom task containers see Unknown Elements in Ant 1.6
  332. - they worked in Ant 1.5?
  333. </a></li>
  334. <li><a href="#java.exception.stacktrace">
  335. The program I run via &lt;java&gt; throws an exception but I
  336. can't seem to get the full stack trace.
  337. </a></li>
  338. </ul>
  339. <h3 class="section">Answers</h3>
  340. <p class="faq">
  341. <a name="latest-version"></a>
  342. Where do I find the latest version of this
  343. document?
  344. </p>
  345. <p>The latest version can always be found at Ant's homepage
  346. <a href="http://ant.apache.org/faq.html">http://ant.apache.org/faq.html</a>.</p>
  347. <p class="faq">
  348. <a name="adding-faqs"></a>
  349. How can I contribute to this FAQ?
  350. </p>
  351. <p>The page you are looking it is generated from
  352. <a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/ant/xdocs/faq.xml">this</a>
  353. document. If you want to add a new question, please submit
  354. a patch against this document to one of Ant's mailing lists;
  355. hopefully, the structure is self-explanatory.</p>
  356. <p>If you don't know how to create a patch, see the patches
  357. section of <a href="http://jakarta.apache.org/site/source.html">this
  358. page</a>.</p>
  359. <p class="faq">
  360. <a name="creating-faq"></a>
  361. How do you create the HTML version of this
  362. FAQ?
  363. </p>
  364. <p>We use
  365. <a href="http://jakarta.apache.org/velocity/anakia.html">Anakia</a>
  366. to render the HTML version from the original XML file.</p>
  367. <p>The Velocity stylesheets used to process the XML files can
  368. be found in the <code>xdocs/stylesheets</code> subdirectory of
  369. Ant's CVS repository - the build file
  370. <code>docs.xml</code> at the top level of the ant CVS
  371. module is used to drive Anakia.</p>
  372. <p>This file assumes that you have the
  373. <code>jakarta-site2</code> CVS module checked out as well, but
  374. if you follow the instruction from Anakia's homepage, you
  375. should get it to work without that. Just make sure all
  376. required jars are in the task's classpath.</p>
  377. <p class="faq">
  378. <a name="what-is-ant"></a>
  379. What is Apache Ant?
  380. </p>
  381. <p> Ant is a Java-based build tool. In theory, it is kind of
  382. like Make, without Make's wrinkles and with the full
  383. portability of pure Java code.</p>
  384. <p class="faq">
  385. <a name="ant-name"></a>
  386. Why do you call it Ant?
  387. </p>
  388. <p>According to Ant's original author, James Duncan
  389. Davidson, the name is an acronym for "Another Neat
  390. Tool".</p>
  391. <p>Later explanations go along the lines of "ants
  392. do an extremely good job at building things", or
  393. "ants are very small and can carry a weight dozens of times
  394. their own" - describing what Ant is intended to
  395. be.</p>
  396. <p class="faq">
  397. <a name="history"></a>
  398. Tell us a little bit about Ant's history.
  399. </p>
  400. <p>Initially, Ant was part of the Tomcat code base, when it was
  401. donated to the Apache Software Foundation. It was
  402. created by James Duncan Davidson, who is also the original
  403. author of Tomcat. Ant was there to build Tomcat, nothing
  404. else.</p>
  405. <p>Soon thereafter, several open source Java projects realized
  406. that Ant could solve the problems they had with Makefiles.
  407. Starting with the projects hosted at Jakarta and the old Java
  408. Apache project, Ant spread like a virus and is now the build
  409. tool of choice for a lot of projects.</p>
  410. <p>In January 2000, Ant was moved to a separate CVS module and
  411. was promoted to a project of its own, independent of
  412. Tomcat, and became Apache Ant.</p>
  413. <p>The first version of Ant that was exposed to a larger audience
  414. was the one that shipped with Tomcat's 3.1 release on 19 April
  415. 2000. This version has later been referred to as Ant
  416. 0.3.1.</p>
  417. <p>The first official release of Ant as a stand-alone product was
  418. Ant 1.1, released on 19 July 2000. The complete release
  419. history:</p>
  420. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  421. <tr>
  422. <th colspan="1" rowspan="1"
  423. valign="top" align="left">
  424. Ant Version
  425. </th>
  426. <th colspan="1" rowspan="1"
  427. valign="top" align="left">
  428. Release Date
  429. </th>
  430. </tr>
  431. <tr>
  432. <td colspan="1" rowspan="1"
  433. valign="top" align="left">
  434. 1.1
  435. </td>
  436. <td colspan="1" rowspan="1"
  437. valign="top" align="left">
  438. 19 July 2000
  439. </td>
  440. </tr>
  441. <tr>
  442. <td colspan="1" rowspan="1"
  443. valign="top" align="left">
  444. 1.2
  445. </td>
  446. <td colspan="1" rowspan="1"
  447. valign="top" align="left">
  448. 24 October 2000
  449. </td>
  450. </tr>
  451. <tr>
  452. <td colspan="1" rowspan="1"
  453. valign="top" align="left">
  454. 1.3
  455. </td>
  456. <td colspan="1" rowspan="1"
  457. valign="top" align="left">
  458. 3 March 2001
  459. </td>
  460. </tr>
  461. <tr>
  462. <td colspan="1" rowspan="1"
  463. valign="top" align="left">
  464. 1.4
  465. </td>
  466. <td colspan="1" rowspan="1"
  467. valign="top" align="left">
  468. 3 September 2001
  469. </td>
  470. </tr>
  471. <tr>
  472. <td colspan="1" rowspan="1"
  473. valign="top" align="left">
  474. 1.4.1
  475. </td>
  476. <td colspan="1" rowspan="1"
  477. valign="top" align="left">
  478. 11 October 2001
  479. </td>
  480. </tr>
  481. <tr>
  482. <td colspan="1" rowspan="1"
  483. valign="top" align="left">
  484. 1.5
  485. </td>
  486. <td colspan="1" rowspan="1"
  487. valign="top" align="left">
  488. 10 July 2002
  489. </td>
  490. </tr>
  491. <tr>
  492. <td colspan="1" rowspan="1"
  493. valign="top" align="left">
  494. 1.5.1
  495. </td>
  496. <td colspan="1" rowspan="1"
  497. valign="top" align="left">
  498. 3 October 2002
  499. </td>
  500. </tr>
  501. <tr>
  502. <td colspan="1" rowspan="1"
  503. valign="top" align="left">
  504. 1.5.2
  505. </td>
  506. <td colspan="1" rowspan="1"
  507. valign="top" align="left">
  508. 3 March 2003
  509. </td>
  510. </tr>
  511. <tr>
  512. <td colspan="1" rowspan="1"
  513. valign="top" align="left">
  514. 1.5.3
  515. </td>
  516. <td colspan="1" rowspan="1"
  517. valign="top" align="left">
  518. 9 April 2003
  519. </td>
  520. </tr>
  521. <tr>
  522. <td colspan="1" rowspan="1"
  523. valign="top" align="left">
  524. 1.5.4
  525. </td>
  526. <td colspan="1" rowspan="1"
  527. valign="top" align="left">
  528. 12 August 2003
  529. </td>
  530. </tr>
  531. <tr>
  532. <td colspan="1" rowspan="1"
  533. valign="top" align="left">
  534. 1.6.0
  535. </td>
  536. <td colspan="1" rowspan="1"
  537. valign="top" align="left">
  538. 18 December 2003
  539. </td>
  540. </tr>
  541. <tr>
  542. <td colspan="1" rowspan="1"
  543. valign="top" align="left">
  544. 1.6.1
  545. </td>
  546. <td colspan="1" rowspan="1"
  547. valign="top" align="left">
  548. 12 February 2004
  549. </td>
  550. </tr>
  551. </table>
  552. <p class="faq">
  553. <a name="no-gnu-tar"></a>
  554. I get checksum errors when I try to extract the
  555. <code>tar.gz</code> distribution file. Why?
  556. </p>
  557. <p>Ant's distribution contains file names that are longer
  558. than 100 characters, which is not supported by the standard
  559. tar file format. Several different implementations of tar use
  560. different and incompatible ways to work around this
  561. restriction.</p>
  562. <p>Ant's &lt;tar&gt; task can create tar archives that use
  563. the GNU tar extension, and this has been used when putting
  564. together the distribution. If you are using a different
  565. version of tar (for example, the one shipping with Solaris),
  566. you cannot use it to extract the archive.</p>
  567. <p>The solution is to either install GNU tar, which can be
  568. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>,
  569. or use the zip archive instead (you can extract it using
  570. <code>jar xf</code>).</p>
  571. <p class="faq">
  572. <a name="adding-external-tasks"></a>
  573. How do I add an external task that I've written to the
  574. page "External Tools and Task"?
  575. </p>
  576. <p>Join and post a message to the dev or user mailing
  577. list (one list is enough), including the following
  578. information:</p>
  579. <ul>
  580. <li>the name of the task/tool</li>
  581. <li>a short description of the task/tool</li>
  582. <li>a Compatibility: entry stating with which version(s) of
  583. Ant the tool/task is compatible to</li>
  584. <li>a URL: entry linking to the main page of the tool/task</li>
  585. <li>a Contact: entry containing the email address or the URL
  586. of a webpage for the person or list to contact for issues
  587. related to the tool/task. <strong>Note that we'll add a
  588. link on the page, so any email address added there is not
  589. obfuscated and can (and probably will) be abused by robots
  590. harvesting websites for addresses to spam.</strong></li>
  591. <li>a License: entry containing the type of license for the
  592. tool/task</li>
  593. </ul>
  594. <p>The preferred format for this information is a patch to <a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/ant/xdocs/external.xml">this</a>
  595. document.</p>
  596. <p class="faq">
  597. <a name="passing-cli-args"></a>
  598. How do I pass parameters from the command line to my
  599. build file?
  600. </p>
  601. <p>Use properties. Using <code>ant
  602. -D<em>name</em>=<em>value</em></code> lets you define values for
  603. properties on the Ant command line. These properties can then be
  604. used within your build file as
  605. any normal property: <code>${<em>name</em>}</code> will put in
  606. <code><em>value</em></code>.</p>
  607. <p class="faq">
  608. <a name="jikes-switches"></a>
  609. How can I use Jikes-specific command-line
  610. switches?
  611. </p>
  612. <p>A couple of switches are supported via "magic"
  613. properties:</p>
  614. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  615. <tr>
  616. <th colspan="1" rowspan="1"
  617. valign="top" align="left">
  618. switch
  619. </th>
  620. <th colspan="1" rowspan="1"
  621. valign="top" align="left">
  622. property
  623. </th>
  624. <th colspan="1" rowspan="1"
  625. valign="top" align="left">
  626. default
  627. </th>
  628. </tr>
  629. <tr>
  630. <td colspan="1" rowspan="1"
  631. valign="top" align="left">
  632. +E
  633. </td>
  634. <td colspan="1" rowspan="1"
  635. valign="top" align="left">
  636. build.compiler.emacs
  637. </td>
  638. <td colspan="1" rowspan="1"
  639. valign="top" align="left">
  640. false == not set
  641. </td>
  642. </tr>
  643. <tr>
  644. <td colspan="1" rowspan="1"
  645. valign="top" align="left">
  646. +P
  647. </td>
  648. <td colspan="1" rowspan="1"
  649. valign="top" align="left">
  650. build.compiler.pedantic
  651. </td>
  652. <td colspan="1" rowspan="1"
  653. valign="top" align="left">
  654. false == not set
  655. </td>
  656. </tr>
  657. <tr>
  658. <td colspan="1" rowspan="1"
  659. valign="top" align="left">
  660. +F
  661. </td>
  662. <td colspan="1" rowspan="1"
  663. valign="top" align="left">
  664. build.compiler.fulldepend
  665. </td>
  666. <td colspan="1" rowspan="1"
  667. valign="top" align="left">
  668. false == not set
  669. </td>
  670. </tr>
  671. <tr>
  672. <td colspan="1" rowspan="1"
  673. valign="top" align="left">
  674. <strong>(Only for Ant &lt; 1.4; replaced by the
  675. <code><strong>nowarn</strong></code>
  676. attribute of the <code><strong>&lt;javac&gt;</strong></code>
  677. task after that.)</strong><br />-nowarn
  678. </td>
  679. <td colspan="1" rowspan="1"
  680. valign="top" align="left">
  681. build.compiler.warnings
  682. </td>
  683. <td colspan="1" rowspan="1"
  684. valign="top" align="left">
  685. true == not set
  686. </td>
  687. </tr>
  688. </table>
  689. <p>With Ant &gt;= 1.5, you can also use nested
  690. <code>&lt;compilerarg&gt;</code> elements with the
  691. <code>&lt;javac&gt;</code> task.</p>
  692. <p class="faq">
  693. <a name="shell-redirect-1"></a>
  694. How do I include a &lt; character in my command-line arguments?
  695. </p>
  696. <p>The short answer is "Use: <code>&amp;lt;</code>".</p>
  697. <p>The long answer is that this probably won't do what you
  698. want anyway (see <a href="#shell-redirect-2">the next
  699. section</a>).</p>
  700. <p class="faq">
  701. <a name="shell-redirect-2"></a>
  702. How do I redirect standard input or standard output
  703. in the <code>&lt;exec&gt;</code> task?
  704. </p>
  705. <p>Say you want to redirect the standard output stream of the
  706. <code>m4</code> command to write to a file, something
  707. like:</p>
  708. <pre class="code">
  709. shell-prompt&gt; m4 foo.m4 &gt; foo
  710. </pre>
  711. <p>and try to translate it into</p>
  712. <pre class="code">
  713. &lt;exec executable=&quot;m4&quot;&gt;
  714. &lt;arg value=&quot;foo.m4&quot;/&gt;
  715. &lt;arg value=&quot;&amp;gt;&quot;/&gt;
  716. &lt;arg value=&quot;foo&quot;/&gt;
  717. &lt;/exec&gt;
  718. </pre>
  719. <p>This will not do what you expect. The output redirection is
  720. performed by your shell, not the command itself, so this
  721. should read:</p>
  722. <pre class="code">
  723. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  724. &lt;arg value=&quot;-c&quot; /&gt;
  725. &lt;arg value=&quot;m4 foo.m4 &amp;gt; foo&quot; /&gt;
  726. &lt;/exec&gt;
  727. </pre>
  728. <p>Note that you must use the <code>value</code> attribute of
  729. <code>&lt;arg&gt;</code> in the last element, in order to have
  730. the command passed as a single, quoted argument. Alternatively,
  731. you can use:</p>
  732. <pre class="code">
  733. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  734. &lt;arg line='-c &quot;m4 foo.m4 &amp;gt; foo&quot;'/&gt;
  735. &lt;/exec&gt;
  736. </pre>
  737. <p>Note the double-quotes nested inside the single-quotes.</p>
  738. <p class="faq">
  739. <a name="batch-shell-execute"></a>
  740. How do I execute a batch file or shell script from Ant?
  741. </p>
  742. <p>On native Unix systems, you should be able to run shell scripts
  743. directly. On systems running a Unix-type shell (for example, Cygwin
  744. on Windows) execute the (command) shell instead - <code>cmd</code>
  745. for batch files, <code>sh</code> for shell scripts - then pass the
  746. batch file or shell script (plus any arguments to the script)
  747. as a single command, using the <code>/c</code> or
  748. <code>-c</code> switch, respectively. See
  749. <a href="#shell-redirect-2">the above section</a>
  750. for example <code>&lt;exec&gt;</code> tasks
  751. executing <code>sh</code>. For batch files, use something like:</p>
  752. <pre class="code">
  753. &lt;exec dir=&quot;.&quot; executable=&quot;cmd&quot; os=&quot;Windows NT&quot;&gt;
  754. &lt;arg line=&quot;/c test.bat&quot;/&gt;
  755. &lt;/exec&gt;
  756. </pre>
  757. <p class="faq">
  758. <a name="multi-conditions"></a>
  759. I want to execute a particular target only if
  760. multiple conditions are true.
  761. </p>
  762. <p>There are actually several answers to this question.</p>
  763. <p>If you have only one set and one unset property to test,
  764. you can specify both an <code>if</code> and an <code>unless</code>
  765. attribute for the target, and they will act as if they
  766. are "anded" together.</p>
  767. <p>If you are using a version of Ant 1.3 or earlier, the
  768. way to work with all other cases is to chain targets together
  769. to determine the specific state you want to test for.</p>
  770. <p>To see how this works, assume you have three properties:
  771. <code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
  772. You want to test that <code>prop1</code> and <code>prop2</code>
  773. are set, and that <code>prop3</code> is not. If the condition
  774. holds true you want to echo "yes".</p>
  775. <p>Here is the implementation in Ant 1.3 and earlier:</p>
  776. <pre class="code">
  777. &lt;target name=&quot;cond&quot; depends=&quot;cond-if&quot;/&gt;
  778. &lt;target name=&quot;cond-if&quot; if=&quot;prop1&quot;&gt;
  779. &lt;antcall target=&quot;cond-if-2&quot;/&gt;
  780. &lt;/target&gt;
  781. &lt;target name=&quot;cond-if-2&quot; if=&quot;prop2&quot;&gt;
  782. &lt;antcall target=&quot;cond-if-3&quot;/&gt;
  783. &lt;/target&gt;
  784. &lt;target name=&quot;cond-if-3&quot; unless=&quot;prop3&quot;&gt;
  785. &lt;echo message=&quot;yes&quot;/&gt;
  786. &lt;/target&gt;
  787. </pre>
  788. <p>Note: <code>&lt;antcall&gt;</code> tasks do <em>not</em> pass
  789. property changes back up to the environment they were called
  790. from, so you would'nt be able to, for example, set a
  791. <code>result</code> property in the <code>cond-if-3</code> target,
  792. then do
  793. <code>&lt;echo message="result is ${result}"/&gt;</code>
  794. in the <code>cond</code> target.</p>
  795. <p>Starting with Ant 1.4, you can use the
  796. <code>&lt;condition&gt;</code> task.</p>
  797. <pre class="code">
  798. &lt;target name=&quot;cond&quot; depends=&quot;cond-if,cond-else&quot;/&gt;
  799. &lt;target name=&quot;check-cond&quot;&gt;
  800. &lt;condition property=&quot;cond-is-true&quot;&gt;
  801. &lt;and&gt;
  802. &lt;not&gt;
  803. &lt;equals arg1=&quot;${prop1}&quot; arg2=&quot;$${prop1}&quot; /&gt;
  804. &lt;/not&gt;
  805. &lt;not&gt;
  806. &lt;equals arg1=&quot;${prop2}&quot; arg2=&quot;$${prop2}&quot; /&gt;
  807. &lt;/not&gt;
  808. &lt;equals arg1=&quot;${prop3}&quot; arg2=&quot;$${prop3}&quot; /&gt;
  809. &lt;/and&gt;
  810. &lt;/condition&gt;
  811. &lt;/target&gt;
  812. &lt;target name=&quot;cond-if&quot; depends=&quot;check-cond&quot; if=&quot;cond-is-true&quot;&gt;
  813. &lt;echo message=&quot;yes&quot;/&gt;
  814. &lt;/target&gt;
  815. &lt;target name=&quot;cond-else&quot; depends=&quot;check-cond&quot; unless=&quot;cond-is-true&quot;&gt;
  816. &lt;echo message=&quot;no&quot;/&gt;
  817. &lt;/target&gt;
  818. </pre>
  819. <p>This version takes advantage of two things:</p>
  820. <ul>
  821. <li>If a property <code>a</code> has not been set,
  822. <code>${a}</code> will evaluate to <code>${a}</code>.</li>
  823. <li>To get a literal <code>$</code> in Ant, you have to
  824. escape it with another <code>$</code> - this will also break
  825. the special treatment of the <code>${</code> sequence.</li>
  826. </ul>
  827. <p>Because testing for a literal <code>${property}</code> string
  828. isn't all that readable or easy to understand,
  829. post-1.4.1 Ant introduces the <code>&lt;isset&gt;</code> element
  830. to the <code>&lt;condition&gt;</code> task.</p>
  831. <p>Here is the previous example done using
  832. <code>&lt;isset&gt;</code>:</p>
  833. <pre class="code">
  834. &lt;target name=&quot;check-cond&quot;&gt;
  835. &lt;condition property=&quot;cond-is-true&quot;&gt;
  836. &lt;and&gt;
  837. &lt;isset property=&quot;prop1&quot;/&gt;
  838. &lt;isset property=&quot;prop2&quot;/&gt;
  839. &lt;not&gt;
  840. &lt;isset property=&quot;prop3&quot;/&gt;
  841. &lt;/not&gt;
  842. &lt;/and&gt;
  843. &lt;/condition&gt;
  844. &lt;/target&gt;
  845. </pre>
  846. <p>The last option is to use a scripting language to set the
  847. properties. This can be particularly handy when you need much
  848. finer control than the simple conditions shown here but, of
  849. course, comes with the overhead of adding JAR files to support
  850. the language, to say nothing of the added maintenance in requiring
  851. two languages to implement a single system. See the
  852. <a href="manual/OptionalTasks/script.html">
  853. <code>&lt;script&gt;</code> task documentation</a> for more
  854. details.</p>
  855. <p class="faq">
  856. <a name="encoding"></a>
  857. How can I include national characters like German
  858. umlauts in my build file?
  859. </p>
  860. <p>You need to tell the XML parser which character encoding
  861. your build file uses, this is done inside the <a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd">XML
  862. declaration</a>.</p>
  863. <p>By default the parser assumes you are using the UTF-8
  864. encoding instead of your platform's default. For most Western
  865. European countries you should set the encoding to
  866. <code>ISO-8859-1</code>. To do so, make the very first line
  867. of you build file read like</p>
  868. <pre class="code">
  869. &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
  870. </pre>
  871. <p class="faq">
  872. <a name="use-zip-instead-of-jar"></a>
  873. How do I use <code>jar</code>'s <code>M</code> switch?
  874. I don't want a MANIFEST.
  875. </p>
  876. <p>A JAR archive is a ZIP file, so if you don't want a
  877. MANIFEST you can simply use <code>&lt;zip&gt;</code>.</p>
  878. <p>If your file names contain national characters you should
  879. know that Sun's <code>jar</code> utility like Ant's
  880. <code>&lt;jar&gt;</code> uses UFT8 to encode their names while
  881. <code>&lt;zip&gt;</code> uses your platforms default encoding.
  882. Use the encoding attribute of <code>&lt;zip&gt;</code> if
  883. necessary.</p>
  884. <p class="faq">
  885. <a name="propertyvalue-as-name-for-property"></a>
  886. How can I do something like <code>&lt;property name="prop"
  887. value="${${anotherprop}}"/&gt;</code> (double expanding the property)?
  888. </p>
  889. <p>Without any external help you can not.</p>
  890. <p>With &lt;script/&gt;, which needs external libraries, you can do</p>
  891. <pre class="code">
  892. &lt;script language=&quot;javascript&quot;&gt;
  893. propname = project.getProperty(&quot;anotherprop&quot;);
  894. project.setNewProperty(&quot;prop&quot;, propname);
  895. &lt;/script&gt;
  896. </pre>
  897. <p>With AntContrib (external task library) you can do <code>
  898. &lt;propertycopy name="prop" from="${anotherprop}"/&gt;</code>.</p>
  899. <p class="faq">
  900. <a name="always-recompiles"></a>
  901. Why does Ant always recompile all my Java files?
  902. </p>
  903. <p>In order to find out which files should be compiled, Ant
  904. compares the timestamps of the source files to those of the
  905. resulting <code>.class</code> files. Opening all source files
  906. to find out which package they belong to would be very
  907. inefficient. Instead, Ant expects you to place your
  908. source files in a directory hierarchy that mirrors your
  909. package hierarchy and to point Ant to the root of this
  910. directory tree with the <code>srcdir</code> attribute.</p>
  911. <p>Say you have <code>&lt;javac srcdir="src"
  912. destdir="dest"/&gt;</code>. If Ant finds a file
  913. <code>src/a/b/C.java</code>, it expects it to be in package
  914. <code>a.b</code> so that the resulting <code>.class</code>
  915. file is going to be <code>dest/a/b/C.class</code>.</p>
  916. <p>If your source-tree directory structure does not match your
  917. package structure, Ant's heuristic won't work, and
  918. it will recompile classes that are up-to-date. Ant is not the
  919. only tool that expects a source-tree layout like this.</p>
  920. <p>If you have Java source files that aren't declared to
  921. be part of any package, you can still use the <code>&lt;javac&gt;</code>
  922. task to compile these files correctly - just set the
  923. <code>srcdir</code> and <code>destdir</code> attributes to
  924. the actual directory the source
  925. files live in and the directory the class files should go into,
  926. respectively.</p>
  927. <p class="faq">
  928. <a name="defaultexcludes"></a>
  929. I've used a <code>&lt;delete&gt;</code> task to
  930. delete unwanted SourceSafe control files (CVS files, editor
  931. backup files, etc.), but it doesn't seem to work; the files
  932. never get deleted. What's wrong?
  933. </p>
  934. <p>This is probably happening because, by default, Ant excludes
  935. SourceSafe control files (<code>vssver.scc</code>) and certain other
  936. files from FileSets.</p>
  937. <p>Here's what you probably did:</p>
  938. <pre class="code">
  939. &lt;delete&gt;
  940. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  941. &lt;/delete&gt;
  942. </pre>
  943. <p>You need to switch off the default exclusions,
  944. and it will work:</p>
  945. <pre class="code">
  946. &lt;delete&gt;
  947. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  948. defaultexcludes=&quot;no&quot;/&gt;
  949. &lt;/delete&gt;
  950. </pre>
  951. <p>For a complete listing of the patterns that are excluded
  952. by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
  953. manual</a>.</p>
  954. <p class="faq">
  955. <a name="stop-dependency"></a>
  956. I have a target I want to skip if a property is set,
  957. so I have <code>unless="property"</code> as an attribute
  958. of the target, but all the targets this target
  959. depends on are still executed. Why?
  960. </p>
  961. <p>The list of dependencies is generated by Ant before any of the
  962. targets are run. This allows dependent targets, such as an
  963. <code>init</code> target, to set properties that can control the
  964. execution of the targets higher in the dependency graph. This
  965. is a good thing.</p>
  966. <p>However, when your dependencies break down the
  967. higher-level task
  968. into several smaller steps, this behaviour becomes
  969. counter-intuitive. There are a couple of solutions available:
  970. </p>
  971. <ol>
  972. <li>Put the same condition on each of the dependent targets.</li>
  973. <li>Execute the steps using <code>&lt;antcall&gt;</code>,
  974. instead of specifying them inside the <code>depends</code>
  975. attribute.</li>
  976. </ol>
  977. <p class="faq">
  978. <a name="include-order"></a>
  979. In my <code>&lt;fileset&gt;</code>, I've put in an
  980. <code>&lt;exclude&gt;</code> of all files followed by an
  981. <code>&lt;include&gt;</code> of just the files I want, but it
  982. isn't giving me any files at all. What's wrong?
  983. </p>
  984. <p>The order of the <code>&lt;include&gt;</code> and
  985. <code>&lt;exclude&gt;</code> tags within a <code>&lt;fileset&gt;</code>
  986. is ignored when the FileSet is created. Instead, all of the
  987. <code>&lt;include&gt;</code> elements are processed together,
  988. followed by all of the <code>&lt;exclude&gt;</code>
  989. elements. This means that the <code>&lt;exclude&gt;</code>
  990. elements only apply to the file list produced by the
  991. <code>&lt;include&gt;</code> elements.</p>
  992. <p>To get the files you want, focus on just the
  993. <code>&lt;include&gt;</code> patterns that would be necessary
  994. to get them. If you find you need to trim the list that the
  995. <code>&lt;include&gt;</code> elements produce, then use
  996. <code>&lt;exclude&gt;</code> elements.</p>
  997. <p class="faq">
  998. <a name="properties-not-trimmed"></a>
  999. <code>ant</code> failed to build my program via javac
  1000. even when I put the needed jars in an external
  1001. <code>build.properties</code> file and reference them by
  1002. <code>pathelement</code> or <code>classpath refid</code>.
  1003. </p>
  1004. <p>When <code>ant</code> loads properties from an external
  1005. file it dosn't touch the value of properties, trailing blanks
  1006. will not be trimmed for example.</p>
  1007. <p>If the value represents a file path, like a jar needed to
  1008. compile, the task which requires the value, javac for example
  1009. would fail to compile since it can't find the file due to
  1010. trailing spaces.</p>
  1011. <p class="faq">
  1012. <a name="winzip-lies"></a>
  1013. Ant creates WAR files with a lower-case
  1014. <code>web-inf</code> or JAR files with a lower-case
  1015. <code>meta-inf</code> directory.
  1016. </p>
  1017. <p>No it doesn't.</p>
  1018. <p>You may have seen these lower-case directory names in
  1019. WinZIP, but WinZIP is trying to be helpful (and fails). If
  1020. WinZIP encounters a filename that is all upper-case, it
  1021. assumes it has come from an old DOS box and changes the case to
  1022. all lower-case for you.</p>
  1023. <p>If you extract (or just check) the archive with jar, you
  1024. will see that the names have the correct case.</p>
  1025. <p>With WinZIP (version 8.1 at least), this can be corrected in the
  1026. configuration. In the Options/Configuration menu, in the View tab, General
  1027. section, check the "Allow all upper case files names" box. The META-INF and
  1028. WEB-INF will look correct.</p>
  1029. <p class="faq">
  1030. <a name="integration"></a>
  1031. Is Ant supported by my IDE/Editor?
  1032. </p>
  1033. <p>See the <a href="external.html#IDE and Editor Integration">section
  1034. on IDE integration</a> on our External Tools and Tasks page.</p>
  1035. <p class="faq">
  1036. <a name="emacs-mode"></a>
  1037. Why doesn't (X)Emacs/vi/MacOS X's project builder
  1038. correctly parse the error messages generated by Ant?
  1039. </p>
  1040. <p>Ant adds a "banner" with the name of the current
  1041. task in front of all logging messages - and there are no built-in
  1042. regular expressions in your editor that would account for
  1043. this.</p>
  1044. <p>You can disable this banner by invoking Ant with the
  1045. <code>-emacs</code> switch. To make Ant autodetect
  1046. Emacs' compile mode, put this into your
  1047. <code>.antrc</code> (contributed by Ville Skytt).</p>
  1048. <pre class="code">
  1049. # Detect (X)Emacs compile mode
  1050. if [ &quot;$EMACS&quot; = &quot;t&quot; ] ; then
  1051. ANT_ARGS=&quot;$ANT_ARGS -emacs&quot;
  1052. ANT_OPTS=&quot;$ANT_OPTS -Dbuild.compiler.emacs=true&quot;
  1053. fi
  1054. </pre>
  1055. <p>Alternatively, you can add the following snippet to your
  1056. <code>.emacs</code> to make Emacs understand Ant's
  1057. output.</p>
  1058. <pre class="code">
  1059. (require 'compile)
  1060. (setq compilation-error-regexp-alist
  1061. (append (list
  1062. ;; works for jikes
  1063. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  1064. ;; works for javac
  1065. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  1066. compilation-error-regexp-alist))
  1067. </pre>
  1068. <p>Yet another alternative that preserves most of Ant's
  1069. formatting is to pipe Ant's output through the following Perl
  1070. script by Dirk-Willem van Gulik:</p>
  1071. <pre class="code">
  1072. #!/usr/bin/perl
  1073. #
  1074. # May 2001 dirkx@apache.org - remove any
  1075. # [foo] lines from the output; keeping
  1076. # spacing more or less there.
  1077. #
  1078. $|=1;
  1079. while(&lt;STDIN&gt;) {
  1080. if (s/^(\s+)\[(\w+)\]//) {
  1081. if ($2 ne $last) {
  1082. print &quot;$1\[$2\]&quot;;
  1083. $s = ' ' x length($2);
  1084. } else {
  1085. print &quot;$1 $s &quot;;
  1086. };
  1087. $last = $2;
  1088. };
  1089. print;
  1090. };
  1091. </pre>
  1092. <p class="faq">
  1093. <a name="dtd"></a>
  1094. Is there a DTD that I can use to validate my build
  1095. files?
  1096. </p>
  1097. <p>An incomplete DTD can be created by the
  1098. <code>&lt;antstructure&gt;</code> task - but this one
  1099. has a few problems:</p>
  1100. <ul>
  1101. <li>It doesn't know about required attributes. Only
  1102. manual tweaking of this file can help here.</li>
  1103. <li>It is not complete - if you add new tasks via
  1104. <code>&lt;taskdef&gt;</code> it won't know about it. See
  1105. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  1106. page</a> by Michel Casabianca for a solution to this
  1107. problem. Note that the DTD you can download at this page
  1108. is based on Ant 0.3.1.</li>
  1109. <li>It may even be an invalid DTD. As Ant allows tasks
  1110. writers to define arbitrary elements, name collisions will
  1111. happen quite frequently - if your version of Ant contains
  1112. the optional <code>&lt;test&gt;</code> and
  1113. <code>&lt;junit&gt;</code> tasks, there are two XML
  1114. elements named <code>test</code> (the task and the nested child
  1115. element of <code>&lt;junit&gt;</code>) with different attribute
  1116. lists. This problem cannot be solved; DTDs don't give a
  1117. syntax rich enough to support this.</li>
  1118. </ul>
  1119. <p class="faq">
  1120. <a name="xml-entity-include"></a>
  1121. How do I include an XML snippet in my build file?
  1122. </p>
  1123. <p>You can use XML's way of including external files and let
  1124. the parser do the job for Ant:</p>
  1125. <pre class="code">
  1126. &lt;?xml version=&quot;1.0&quot;?&gt;
  1127. &lt;!DOCTYPE project [
  1128. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  1129. ]&gt;
  1130. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1131. &lt;target name=&quot;setup&quot;&gt;
  1132. ...
  1133. &lt;/target&gt;
  1134. &amp;common;
  1135. ...
  1136. &lt;/project&gt;
  1137. </pre>
  1138. <p>will literally include the contents of <code>common.xml</code> where
  1139. you've placed the <code>&amp;common;</code> entity.</p>
  1140. <p>In combination with a DTD, this would look like this:</p>
  1141. <pre class="code">
  1142. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  1143. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  1144. ]&gt;
  1145. </pre>
  1146. <p>Starting with Ant 1.6, there is a new
  1147. <code>&lt;import&gt;</code> task that can (also) be used to
  1148. include build file fragments. Unlike the snippets used with
  1149. entity includes, the referenced files have to be complete Ant
  1150. build files, though.</p>
  1151. <p>The example above would become:</p>
  1152. <pre class="code">
  1153. &lt;?xml version=&quot;1.0&quot;?&gt;
  1154. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1155. &lt;target name=&quot;setup&quot;&gt;
  1156. ...
  1157. &lt;/target&gt;
  1158. &lt;import file=&quot;./common.xml&quot;/&gt;
  1159. ...
  1160. &lt;/project&gt;
  1161. </pre>
  1162. <p>Unlike entity includes, <code>&lt;import&gt;</code> will
  1163. let you use Ant properties in the file name.</p>
  1164. <p class="faq">
  1165. <a name="mail-logger"></a>
  1166. How do I send an email with the result of my build
  1167. process?
  1168. </p>
  1169. <p>If you are using a nightly build of Ant 1.5 after
  1170. 2001-12-14, you can use the built-in MailLogger:</p>
  1171. <pre class="code">
  1172. ant -logger org.apache.tools.ant.listener.MailLogger
  1173. </pre>
  1174. <p>See the <a href="http://cvs.apache.org/viewcvs/~checkout~/ant/docs/manual/listeners.html?content-type=text/html">Listeners
  1175. &amp; Loggers</a> documentation for details on the properties
  1176. required.</p>
  1177. <p>For older versions of Ant, you can use a custom
  1178. BuildListener that sends out an email
  1179. in the buildFinished() method. Will Glozer
  1180. &lt;will.glozer@jda.com&gt; has written such a listener based
  1181. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
  1182. The source is:</p>
  1183. <pre class="code">
  1184. import java.io.*;
  1185. import java.util.*;
  1186. import javax.mail.*;
  1187. import javax.mail.internet.*;
  1188. import org.apache.tools.ant.*;
  1189. /**
  1190. * A simple listener that waits for a build to finish and sends an email
  1191. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1192. * are fairly self explanatory.
  1193. *
  1194. * @author Will Glozer
  1195. * @version 1.05a 09/06/2000
  1196. */
  1197. public class BuildMonitor implements BuildListener {
  1198. protected Properties props;
  1199. /**
  1200. * Create a new BuildMonitor.
  1201. */
  1202. public BuildMonitor() throws Exception {
  1203. props = new Properties();
  1204. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1205. props.load(is);
  1206. is.close();
  1207. }
  1208. public void buildStarted(BuildEvent e) {
  1209. }
  1210. /**
  1211. * Determine the status of the build and the actions to follow, now that
  1212. * the build has completed.
  1213. *
  1214. * @param e Event describing the build status.
  1215. */
  1216. public void buildFinished(BuildEvent e) {
  1217. Throwable th = e.getException();
  1218. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1219. try {
  1220. String key = &quot;build.&quot; + status;
  1221. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1222. return;
  1223. }
  1224. Session session = Session.getDefaultInstance(props, null);
  1225. MimeMessage message = new MimeMessage(session);
  1226. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1227. props.getProperty(key + &quot;.email.to&quot;)));
  1228. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1229. BufferedReader br = new BufferedReader(new FileReader(
  1230. props.getProperty(&quot;build.log&quot;)));
  1231. StringWriter sw = new StringWriter();
  1232. String line = br.readLine();
  1233. while (line != null) {
  1234. sw.write(line);
  1235. sw.write(&quot;\n&quot;);
  1236. line = br.readLine();
  1237. }
  1238. br.close();
  1239. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1240. sw.close();
  1241. Transport transport = session.getTransport();
  1242. transport.connect();
  1243. transport.send(message);
  1244. transport.close();
  1245. } catch (Exception ex) {
  1246. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1247. ex.printStackTrace();
  1248. }
  1249. }
  1250. /**
  1251. * Parse a comma separated list of internet email addresses.
  1252. *
  1253. * @param s The list of addresses.
  1254. * @return Array of Addresses.
  1255. */
  1256. protected Address[] parseAddresses(String s) throws Exception {
  1257. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1258. Address[] addrs = new Address[st.countTokens()];
  1259. for (int i = 0; i &lt; addrs.length; i++) {
  1260. addrs[i] = new InternetAddress(st.nextToken());
  1261. }
  1262. return addrs;
  1263. }
  1264. public void messageLogged(BuildEvent e) {
  1265. }
  1266. public void targetStarted(BuildEvent e) {
  1267. }
  1268. public void targetFinished(BuildEvent e) {
  1269. }
  1270. public void taskStarted(BuildEvent e) {
  1271. }
  1272. public void taskFinished(BuildEvent e) {
  1273. }
  1274. }
  1275. </pre>
  1276. <p>With a <code>monitor.properties</code> like this:</p>
  1277. <pre class="code">
  1278. # configuration for build monitor
  1279. mail.transport.protocol=smtp
  1280. mail.smtp.host=&lt;host&gt;
  1281. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1282. build.log=build.log
  1283. build.failed.notify=true
  1284. build.failed.email.to=will.glozer@jda.com
  1285. build.failed.email.subject=Nightly build failed!
  1286. build.succeeded.notify=true
  1287. build.succeeded.email.to=will.glozer@jda.com
  1288. build.succeeded.email.subject=Nightly build succeeded!
  1289. </pre>
  1290. <p><code>monitor.properties</code> should be placed right next
  1291. to your compiled <code>BuildMonitor.class</code>. To use it,
  1292. invoke Ant like:</p>
  1293. <pre class="code">
  1294. ant -listener BuildMonitor -logfile build.log
  1295. </pre>
  1296. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1297. <code>activation.jar</code> from the
  1298. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1299. Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
  1300. <p class="faq">
  1301. <a name="listener-properties"></a>
  1302. How do I get at the properties that Ant was running
  1303. with from inside BuildListener?
  1304. </p>
  1305. <p>You can get at a hashtable with all the properties that Ant
  1306. has been using through the BuildEvent parameter. For
  1307. example:</p>
  1308. <pre class="code">
  1309. public void buildFinished(BuildEvent e) {
  1310. Hashtable table = e.getProject().getProperties();
  1311. String buildpath = (String)table.get(&quot;build.path&quot;);
  1312. ...
  1313. }
  1314. </pre>
  1315. <p>This is more accurate than just reading the same property
  1316. files that your project does, since it will give the correct
  1317. results for properties that were specified on the Ant command line.</p>
  1318. <p class="faq">
  1319. <a name="remove-cr"></a>
  1320. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  1321. 1.3 on Unix
  1322. </p>
  1323. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1324. has DOS instead of Unix line endings; you must remove the
  1325. carriage-return characters from this file. This can be done by
  1326. using Ant's <code>&lt;fixcrlf&gt;</code> task
  1327. or something like:</p>
  1328. <pre class="code">
  1329. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1330. mv /tmp/foo $ANT_HOME/bin/antRun
  1331. </pre>
  1332. <p class="faq">
  1333. <a name="javadoc-cannot-execute"></a>
  1334. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1335. </p>
  1336. <p>There is a bug in the Solaris reference implementation of
  1337. 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>).
  1338. This also appears to be true under Linux. Moving the JDK to
  1339. the front of the PATH fixes the problem.</p>
  1340. <p class="faq">
  1341. <a name="delegating-classloader"></a>
  1342. &lt;style&gt; or &lt;junit&gt; ignores my
  1343. &lt;classpath&gt;
  1344. </p>
  1345. <p>These tasks don't ignore your classpath setting, you
  1346. are facing a common problem with delegating classloaders.</p>
  1347. <p>First of all let's state that Ant adds all
  1348. <code>.jar</code> files from <code>ANT_HOME/lib</code> to
  1349. <code>CLASSPATH</code>, therefore "in
  1350. <code>CLASSPATH</code>" shall mean "either in your
  1351. <code>CLASSPATH</code> environment variable or
  1352. <code>ANT_HOME/lib</code>" for the rest of this
  1353. answer.</p>
  1354. <p>Technically the sentence above isn't true for Ant 1.6
  1355. and later anymore, but the result is the same. For the sake
  1356. of this discussion, <code>CLASSPATH</code> and
  1357. <code>ANT_HOME/lib</code> are identical.</p>
  1358. <p>This question collects a common type of problem: A task
  1359. needs an external library and it has a nested classpath
  1360. element so that you can point it to this external library, but
  1361. that doesn't work unless you put the external library into the
  1362. <code>CLASSPATH</code>.</p>
  1363. <p>The root of the problem is that the class that needs the
  1364. external library is on the <code>CLASSPATH</code>.</p>
  1365. <p>When you specify a nested <code>&lt;classpath&gt;</code> in
  1366. Ant, Ant creates a new class loader that uses the path you
  1367. have specified. It then tries to load additional classes from
  1368. this classloader.</p>
  1369. <p>In most cases - for example the two cases above - Ant
  1370. doesn't load the external library directly, it is the loaded
  1371. class that does so.</p>
  1372. <p>In the case of <code>&lt;junit&gt;</code> it is the task
  1373. implementation itself and in the case of
  1374. <code>&lt;style&gt;</code> it is the implementation of the
  1375. <code>org.apache.tools.ant.taskdefs.XSLTLiaison</code>
  1376. class.</p>
  1377. <p>Ant's class loader implementation uses Java's
  1378. delegation model, see <a 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>
  1379. the paragraph</p>
  1380. <blockquote>The <code>ClassLoader</code> class uses a
  1381. delegation model to search for classes and resources. Each
  1382. instance of <code>ClassLoader</code> has an associated parent
  1383. class loader. When called upon to find a class or resource, a
  1384. <code>ClassLoader</code> instance will delegate the search for
  1385. the class or resource to its parent class loader before
  1386. attempting to find the class or resource itself. The virtual
  1387. machine's built-in class loader, called the bootstrap
  1388. class loader, does not itself have a parent but may serve as
  1389. the parent of a <code>ClassLoader</code>
  1390. instance.</blockquote>
  1391. <p>This means, Ant's class loader will consult the
  1392. bootstrap class loader first, which tries to load classes from
  1393. <code>CLASSPATH</code>. The bootstrap class loader
  1394. doesn't know anything about Ant's class loader or
  1395. even the path you have specified.</p>
  1396. <p>If the bootstrap class loader can load the class Ant has
  1397. asked it to load, this class will try to load the external
  1398. library from <code>CLASSPATH</code> as well - it doesn't
  1399. know anything else - and will not find it unless the library
  1400. is in <code>CLASSPATH</code> as well.</p>
  1401. <p>To solve this, you have two major options:</p>
  1402. <ol>
  1403. <li>put all external libraries you need in
  1404. <code>CLASSPATH</code> as well this is not what you want,
  1405. otherwise you wouldn't have found this FAQ entry.</li>
  1406. <li>remove the class that loads the external library from
  1407. the <code>CLASSPATH</code>.</li>
  1408. </ol>
  1409. <p><strong>Using The Second Option with Ant 1.5.4 and
  1410. Earlier:</strong></p>
  1411. <p>The easiest way to do this is to remove
  1412. <code>optional.jar</code> from <code>ANT_HOME/lib</code>. If
  1413. you do so, you will have to <code>&lt;taskdef&gt;</code> all
  1414. optional tasks and use nested <code>&lt;classpath&gt;</code>
  1415. elements in the <code>&lt;taskdef&gt;</code> tasks that point
  1416. to the new location of <code>optional.jar</code>. Also,
  1417. don't forget to add the new location of
  1418. <code>optional.jar</code> to the
  1419. <code>&lt;classpath&gt;</code> of your
  1420. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code>
  1421. task.</p>
  1422. <p>If you want to avoid to <code>&lt;taskdef&gt;</code> all
  1423. optional tasks you need, the only other option is to remove
  1424. the classes that should not be loaded via the bootstrap class
  1425. loader from <code>optional.jar</code> and put them into a
  1426. separate archive. Add this separate archive to the
  1427. <code>&lt;classpath&gt;</code> of your
  1428. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code> task
  1429. - and make sure the separate archive is not in
  1430. <code>CLASSPATH</code>.</p>
  1431. <p>In the case of <code>&lt;junit&gt;</code> you'd have
  1432. to remove all classes that are in the
  1433. <code>org/apache/tools/ant/taskdefs/optional/junit</code>
  1434. directory, in the <code>&lt;style&gt;</code> case it is one of
  1435. the <code>*Liaison</code> classes in
  1436. <code>org/apache/tools/ant/taskdefs/optional</code>.</p>
  1437. <p><strong>Using The Second Option with Ant 1.6 and
  1438. later:</strong></p>
  1439. <p>In Ant 1.6 <code>optional.jar</code> has been split into
  1440. multiple jars, each one containing classes with the same
  1441. dependencies on external libraries. You can move the
  1442. "offending" jar out of ANT_HOME/lib. For the
  1443. <code>&lt;junit&gt;</code> task it would be
  1444. <code>ant-junit.jar</code> and for <code>&lt;style&gt;</code>
  1445. it would be <code>ant-trax.jar</code>,
  1446. <code>ant-xalan1.jar</code> or <code>ant-xslp.jar</code> -
  1447. depending on the processor you use.</p>
  1448. <p>If you use the option to break up <code>optional.jar</code>
  1449. for <code>&lt;junit&gt;</code> or remove
  1450. <code>ant-junit.jar</code>, you still have to use a
  1451. <code>&lt;taskdef&gt;</code> with a nested
  1452. <code>&lt;classpath&gt;</code> to define the junit task.</p>
  1453. <p class="faq">
  1454. <a name="winxp-jdk14-ant14"></a>
  1455. When running Ant 1.4 on Windows XP and JDK 1.4, I get
  1456. various errors when trying to <code>&lt;exec&gt;</code>, fork
  1457. <code>&lt;java&gt;</code> or access environment
  1458. variables.
  1459. </p>
  1460. <p>Ant &lt; 1.5 doesn't recognize Windows XP as a flavor
  1461. of Windows that runs <code>CMD.EXE</code> instead of
  1462. <code>COMMAND.COM</code>. JDK 1.3 will tell Ant that Windows
  1463. XP is Windows 2000 so the problem doesn't show up
  1464. there.</p>
  1465. <p>Apart from upgrading to Ant 1.5 or better, setting the
  1466. environment variable <code>ANT_OPTS</code> to
  1467. <code>-Dos.name=Windows_NT</code> prior to invoking Ant has
  1468. been confirmed as a workaround.</p>
  1469. <p class="faq">
  1470. <a name="1.5-cygwin-sh"></a>
  1471. The <code>ant</code> wrapper script of Ant 1.5 fails
  1472. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  1473. path.
  1474. </p>
  1475. <p>This problem has been reported only hours after Ant 1.5 has
  1476. been released, see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=10664">Bug
  1477. 10664</a> and all its duplicates.</p>
  1478. <p>A fixed version of the wrapper script can be found <a href="http://ant.apache.org/old-releases/v1.5/errata/">here</a>.
  1479. Simply replace your script with this version.</p>
  1480. <p class="faq">
  1481. <a name="1.5.2-zip-broken"></a>
  1482. <code>&lt;zip&gt;</code> is broken in Ant 1.5.2.
  1483. </p>
  1484. <p>Yes, it is.</p>
  1485. <p>The problem reported by most people - see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17648">Bug
  1486. 17648</a> and all its duplicates - is that Ant creates
  1487. archives that a partially unreadable by WinZIP. Luckily
  1488. <code>jar</code> deals with the archives and so the generated
  1489. jars/wars/ears will most likely work for you anyway.</p>
  1490. <p>There are additional problems, see bugs <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17780">Bug
  1491. 17780</a>, <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17871">Bug
  1492. 17871</a> and <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=18403">Bug
  1493. 18403</a>. All of them are supposed to be fixed with Ant
  1494. 1.5.3 (and only 18403 should exist in 1.5.3beta1).</p>
  1495. <p class="faq">
  1496. <a name="unknownelement.taskcontainer"></a>
  1497. Why do my custom task containers see Unknown Elements in Ant 1.6
  1498. - they worked in Ant 1.5?
  1499. </p>
  1500. <p>
  1501. The objects added in TaskContainer.addTask(Task task)
  1502. have changed from Tasks to UnknownElements.
  1503. </p>
  1504. <p>
  1505. There was a number of valid reasons for this change. But the backward
  1506. compatibility problems were not noticed until after Ant 1.6.0 was
  1507. released.
  1508. </p>
  1509. <p>
  1510. Your container class will need to be modified to check if the Task
  1511. is an UnknownElement and call perform on it to
  1512. convert it to a Task and to execute it.
  1513. (see apache.tools.ant.taskdefs.Sequential)
  1514. </p>
  1515. <p>
  1516. If you want to do more processing on the task,
  1517. you need to use the techniques in apache.tools.ant.taskdefs.Antlib#execute()
  1518. This does make use of one 1.6 method call (UE#getRealObject()),
  1519. you need to use UE#getTask() instead - this will
  1520. return null for non tasks (types like fileset id=x).
  1521. </p>
  1522. <p>
  1523. So.. iterate over the tasks, if they are UEs, convert them to
  1524. tasks, using UE#maybeConfigure and UE#getTask()
  1525. </p>
  1526. <pre class="code">
  1527. for (Iterator i = tasks.iterator(); i.hasNext();) {
  1528. Task t = (Task) i.next();
  1529. if (t instanceof UnknownElement) {
  1530. ((UnknownElement) t).maybeConfigure();
  1531. t = ((UnknownElement) t).getTask();
  1532. if (t == null) {
  1533. continue;
  1534. }
  1535. }
  1536. // .... original Custom code
  1537. }
  1538. </pre>
  1539. <p>
  1540. This approach should work for ant1.5 and ant1.6.
  1541. </p>
  1542. <p class="faq">
  1543. <a name="java.exception.stacktrace"></a>
  1544. The program I run via &lt;java&gt; throws an exception but I
  1545. can't seem to get the full stack trace.
  1546. </p>
  1547. <p>This is a know bug that has been fixed after the release of
  1548. Ant 1.6.1.</p>
  1549. <p>As a workaround, run your &lt;java&gt; task with
  1550. <code>fork="true"</code> and Ant will display the full
  1551. trace.</p>
  1552. </div>
  1553. </div>
  1554. <p class="copyright">
  1555. Copyright &copy; 2000-2004&nbsp;The Apache Software Foundation. All rights reserved.
  1556. <script type="text/javascript" language="JavaScript"><!--
  1557. document.write(" - "+"Last Published: " + document.lastModified);
  1558. // -->
  1559. </script>
  1560. </p>
  1561. </body>
  1562. </html>