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 95 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
  18. <head>
  19. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  20. <title>Apache Ant - Frequently Asked Questions</title>
  21. <link type="text/css" href="./page.css" rel="stylesheet">
  22. <meta name="author" content="Stefan Bodewig">
  23. <meta name="email" content="bodewig@apache.org">
  24. </head>
  25. <body>
  26. <p class="navpath">
  27. <script src="./breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
  28. </p>
  29. <div class="logobar">
  30. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  31. <tr>
  32. <td align="left"><img border="0" alt="Apache Ant site" src="./images/group-logo.gif"></td>
  33. <td align="center" width="100%"><img alt="Apache Ant logo" border="0" src="./images/project-logo.gif"></td>
  34. <td align="right">
  35. <form target="_blank" onsubmit="q.value = query.value + ' site:ant.apache.org'" action="http://www.google.com/search" method="get">
  36. <table summary="search" border="0" cellspacing="0" cellpadding="0" bgcolor="#4C6C8F">
  37. <tr>
  38. <td colspan="3"><img height="10" width="1" alt="" src="./images/spacer.gif"></td>
  39. </tr>
  40. <tr>
  41. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  42. <td nowrap="nowrap" class="searchcaption">
  43. <input name="q" type="hidden">
  44. <input size="15" id="query" type="text">
  45. <img height="1" width="5" alt="" src="./images/spacer.gif">
  46. <input name="Search" value="Search" type="submit">
  47. <br>
  48. the Apache Ant site
  49. </td>
  50. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  51. </tr>
  52. <tr>
  53. <td><img alt="" border="0" height="10" width="9" src="./images/search-left.gif"></td>
  54. <td><img height="1" width="1" alt="" src="./images/spacer.gif"></td>
  55. <td><img alt="" border="0" height="10" width="9" src="./images/search-right.gif"></td>
  56. </tr>
  57. </table>
  58. </form>
  59. </td>
  60. </tr>
  61. </table>
  62. </div>
  63. <div class="tab">
  64. <table summary="tab bar" border="0" cellpadding="0" cellspacing="0">
  65. <tr>
  66. <td width="8"><img alt="" height="5" width="8" src="./images/spacer.gif"></td><td valign="bottom">
  67. <table summary="selected tab" style="height: 1.5em" border="0" cellpadding="0" cellspacing="0">
  68. <tr>
  69. <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>
  70. </tr>
  71. </table>
  72. </td>
  73. <td width="5"><img alt="" height="8" width="8" src="./images/spacer.gif"></td><td valign="bottom">
  74. <table summary="non selected tab" style="height: 1.4em" border="0" cellpadding="0" cellspacing="0">
  75. <tr>
  76. <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>
  77. </tr>
  78. </table>
  79. </td>
  80. </tr>
  81. </table>
  82. </div>
  83. <div class="bluebar"></div>
  84. <div class="menucontainer">
  85. <div class="menu">
  86. <ul>
  87. <li class="menuheader">Apache Ant
  88. <ul>
  89. <li>
  90. <a href="./index.html">Welcome</a>
  91. </li>
  92. <li>
  93. <a href="./license.html">License</a>
  94. </li>
  95. <li>
  96. <a href="./antnews.html">News</a>
  97. </li>
  98. </ul>
  99. </li>
  100. <li class="menuheader">Documentation
  101. <ul>
  102. <li>
  103. <a href="./manual/index.html">Manual</a>
  104. </li>
  105. <li>
  106. <a href="./projects.html">Related Projects</a>
  107. </li>
  108. <li>
  109. <a href="./external.html">External Tools and Tasks</a>
  110. </li>
  111. <li>
  112. <a href="./resources.html">Resources</a>
  113. </li>
  114. <li>
  115. <span class="sel">Frequently Asked Questions</span>
  116. </li>
  117. <li>
  118. <a href="http://wiki.apache.org/ant/FrontPage">Wiki</a>
  119. </li>
  120. <li>
  121. <a href="./problems.html">Having Problems?</a>
  122. </li>
  123. </ul>
  124. </li>
  125. <li class="menuheader">Download
  126. <ul>
  127. <li>
  128. <a href="http://ant.apache.org/bindownload.cgi">Binary Distributions</a>
  129. </li>
  130. <li>
  131. <a href="http://ant.apache.org/srcdownload.cgi">Source Distributions</a>
  132. </li>
  133. </ul>
  134. </li>
  135. <li class="menuheader">Contributing
  136. <ul>
  137. <li>
  138. <a href="./mail.html">Mailing Lists</a>
  139. </li>
  140. <li>
  141. <a href="./svn.html">Subversion Repositories</a>
  142. </li>
  143. <li>
  144. <a href="./nightlies.html">Nightly Builds</a>
  145. </li>
  146. <li>
  147. <a href="./bugs.html">Bug Database</a>
  148. </li>
  149. </ul>
  150. </li>
  151. <li class="menuheader">Sponsorship
  152. <ul>
  153. <li>
  154. <a href="http://www.apache.org/foundation/thanks.html">Thanks</a>
  155. </li>
  156. <li>
  157. <a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a>
  158. </li>
  159. <li>
  160. <a href="http://www.apache.org/foundation/contributing.html">Donations</a>
  161. </li>
  162. </ul>
  163. </li>
  164. <li class="menuheader">Project Management
  165. <ul>
  166. <li>
  167. <a href="./contributors.html">Contributors</a>
  168. </li>
  169. <li>
  170. <a href="./mission.html">Apache Ant Mission</a>
  171. </li>
  172. <li>
  173. <a href="./bylaws.html">Project Bylaws</a>
  174. </li>
  175. <li>
  176. <a href="./legal.html">Legal</a>
  177. </li>
  178. </ul>
  179. </li>
  180. </ul>
  181. </div>
  182. <center>
  183. <!--#include virtual="/ads/buttonbar.html" -->
  184. </center>
  185. <img style="float: left" height="10" width="10" border="0" alt="" src="./images/menu-left.gif">
  186. <img style="float: right" height="10" width="10" border="0" alt="" src="./images/menu-right.gif">
  187. </div>
  188. <div class="lightbluebar">&nbsp;</div>
  189. <div class="main">
  190. <div class="content">
  191. <h1 class="title">Frequently Asked Questions</h1>
  192. <h3 class="section">Questions</h3>
  193. <h4 class="toc">About this FAQ</h4>
  194. <ul>
  195. <li><a href="#latest-version">
  196. Where do I find the latest version of this
  197. document?
  198. </a></li>
  199. <li><a href="#adding-faqs">
  200. How can I contribute to this FAQ?
  201. </a></li>
  202. <li><a href="#creating-faq">
  203. How do you create the HTML version of this
  204. FAQ?
  205. </a></li>
  206. </ul>
  207. <h4 class="toc">General</h4>
  208. <ul>
  209. <li><a href="#what-is-ant">
  210. What is Apache Ant?
  211. </a></li>
  212. <li><a href="#ant-name">
  213. Why do you call it Ant?
  214. </a></li>
  215. <li><a href="#history">
  216. Tell us a little bit about Ant's history.
  217. </a></li>
  218. </ul>
  219. <h4 class="toc">Installation</h4>
  220. <ul>
  221. <li><a href="#java-version">
  222. Which version of Java is required to run
  223. Ant?
  224. </a></li>
  225. <li><a href="#no-gnu-tar">
  226. I get checksum errors when I try to extract the
  227. <code>tar.gz</code> distribution file. Why?
  228. </a></li>
  229. <li><a href="#RedHat_ES_3">
  230. How do you get ant-1.6.x (or any version later than
  231. 1.5.2) to work on on RedHat ES 3?
  232. </a></li>
  233. </ul>
  234. <h4 class="toc">How do I ...</h4>
  235. <ul>
  236. <li><a href="#implement-os-specific-configuration">
  237. How do I realize os--specific configurations?
  238. </a></li>
  239. <li><a href="#adding-external-tasks">
  240. How do I add an external task that I've written to the
  241. page "External Tools and Tasks"?
  242. </a></li>
  243. <li><a href="#create-extensions">
  244. How do I create new tasks?
  245. </a></li>
  246. <li><a href="#passing-cli-args">
  247. How do I pass parameters from the command line to my
  248. build file?
  249. </a></li>
  250. <li><a href="#jikes-switches">
  251. How can I use Jikes-specific command-line
  252. switches?
  253. </a></li>
  254. <li><a href="#shell-redirect-1">
  255. How do I include a &lt; character in my command-line arguments?
  256. </a></li>
  257. <li><a href="#shell-redirect-2">
  258. How do I redirect standard input or standard output
  259. in the <code>&lt;exec&gt;</code> task?
  260. </a></li>
  261. <li><a href="#batch-shell-execute">
  262. How do I execute a batch file or shell script from Ant?
  263. </a></li>
  264. <li><a href="#multi-conditions">
  265. I want to execute a particular target only if
  266. multiple conditions are true.
  267. </a></li>
  268. <li><a href="#encoding">
  269. How can I include national characters like German
  270. umlauts in my build file?
  271. </a></li>
  272. <li><a href="#use-zip-instead-of-jar">
  273. How do I use <code>jar</code>'s <code>M</code> switch?
  274. I don't want a MANIFEST.
  275. </a></li>
  276. <li><a href="#propertyvalue-as-name-for-property">
  277. How can I do something like <code>&lt;property name="prop"
  278. value="${${anotherprop}}"/&gt;</code> (double expanding the property)?
  279. </a></li>
  280. <li><a href="#delete-directory-children-only">
  281. How can I delete everything beneath a particular directory,
  282. preserving the directory itself?
  283. </a></li>
  284. </ul>
  285. <h4 class="toc">It doesn't work (as expected)</h4>
  286. <ul>
  287. <li><a href="#general-advice">
  288. General Advice
  289. </a></li>
  290. <li><a href="#always-recompiles">
  291. Why does Ant always recompile all my Java files?
  292. </a></li>
  293. <li><a href="#defaultexcludes">
  294. I've used a <code>&lt;delete&gt;</code> task to
  295. delete unwanted SourceSafe control files (CVS files, editor
  296. backup files, etc.), but it doesn't seem to work; the files
  297. never get deleted. What's wrong?
  298. </a></li>
  299. <li><a href="#stop-dependency">
  300. I have a target I want to skip if a property is set,
  301. so I have <code>unless="property"</code> as an attribute
  302. of the target, but all the targets this target
  303. depends on are still executed. Why?
  304. </a></li>
  305. <li><a href="#include-order">
  306. In my <code>&lt;fileset&gt;</code>, I've put in an
  307. <code>&lt;exclude&gt;</code> of all files followed by an
  308. <code>&lt;include&gt;</code> of just the files I want, but it
  309. isn't giving me any files at all. What's wrong?
  310. </a></li>
  311. <li><a href="#properties-not-trimmed">
  312. <code>ant</code> failed to build my program via javac
  313. even when I put the needed jars in an external
  314. <code>build.properties</code> file and reference them by
  315. <code>pathelement</code> or <code>classpath refid</code>.
  316. </a></li>
  317. <li><a href="#winzip-lies">
  318. Ant creates WAR files with a lower-case
  319. <code>web-inf</code> or JAR files with a lower-case
  320. <code>meta-inf</code> directory.
  321. </a></li>
  322. <li><a href="#NoClassDefFoundError">
  323. I installed Ant 1.6.x and now get
  324. <code>Exception in thread "main" java.lang.NoClassDefFoundError:
  325. </code>
  326. </a></li>
  327. <li><a href="#InstantiationException">
  328. I installed Ant 1.6.x and now get
  329. <code>java.lang.InstantiationException: org.apache.tools.ant.Main</code>
  330. </a></li>
  331. <li><a href="#mangled-manifest">
  332. Whenever I use the Ant jar or manifest related tasks, long lines in
  333. my manifest are wrapped at 70 characters and the resulting jar does
  334. not work in my application server. Why does Ant do this?
  335. </a></li>
  336. </ul>
  337. <h4 class="toc">Ant and IDEs/Editors</h4>
  338. <ul>
  339. <li><a href="#integration">
  340. Is Ant supported by my IDE/Editor?
  341. </a></li>
  342. <li><a href="#emacs-mode">
  343. Why doesn't (X)Emacs/vi/MacOS X's project builder
  344. correctly parse the error messages generated by Ant?
  345. </a></li>
  346. </ul>
  347. <h4 class="toc">Advanced Issues</h4>
  348. <ul>
  349. <li><a href="#dtd">
  350. Is there a DTD that I can use to validate my build
  351. files?
  352. </a></li>
  353. <li><a href="#xml-entity-include">
  354. How do I include an XML snippet in my build file?
  355. </a></li>
  356. <li><a href="#mail-logger">
  357. How do I send an email with the result of my build
  358. process?
  359. </a></li>
  360. <li><a href="#listener-properties">
  361. How do I get at the properties that Ant was running
  362. with from inside BuildListener?
  363. </a></li>
  364. </ul>
  365. <h4 class="toc">Known Problems</h4>
  366. <ul>
  367. <li><a href="#input-makes-exec-hang">
  368. <code>&lt;exec&gt;</code> causes other tasks to hang
  369. or leads to strange behaviour of <code>&lt;input&gt;</code>
  370. tasks.
  371. </a></li>
  372. <li><a href="#170-requires-junit">
  373. Ant 1.7.0 doesn't build from sources without
  374. JUnit
  375. </a></li>
  376. <li><a href="#remove-cr">
  377. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  378. 1.3 on Unix
  379. </a></li>
  380. <li><a href="#javadoc-cannot-execute">
  381. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  382. </a></li>
  383. <li><a href="#delegating-classloader">
  384. &lt;style&gt; or &lt;junit&gt; ignores my
  385. &lt;classpath&gt;
  386. </a></li>
  387. <li><a href="#delegating-classloader-1.5">
  388. &lt;style&gt; or &lt;junit&gt; ignores my
  389. &lt;classpath&gt; - Ant 1.5.x version
  390. </a></li>
  391. <li><a href="#delegating-classloader-1.6">
  392. &lt;style&gt; or &lt;junit&gt; ignores my
  393. &lt;classpath&gt; - Ant 1.6.x version
  394. </a></li>
  395. <li><a href="#winxp-jdk14-ant14">
  396. When running Ant 1.4 on Windows XP and JDK 1.4, I get
  397. various errors when trying to <code>&lt;exec&gt;</code>, fork
  398. <code>&lt;java&gt;</code> or access environment
  399. variables.
  400. </a></li>
  401. <li><a href="#1.5-cygwin-sh">
  402. The <code>ant</code> wrapper script of Ant 1.5 fails
  403. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  404. path.
  405. </a></li>
  406. <li><a href="#1.5.2-zip-broken">
  407. <code>&lt;zip&gt;</code> is broken in Ant 1.5.2.
  408. </a></li>
  409. <li><a href="#unknownelement.taskcontainer">
  410. Why do my custom task containers see Unknown Elements in Ant 1.6
  411. - they worked in Ant 1.5?
  412. </a></li>
  413. <li><a href="#java.exception.stacktrace">
  414. The program I run via &lt;java&gt; throws an exception but I
  415. can't seem to get the full stack trace.
  416. </a></li>
  417. <li><a href="#junit-no-runtime-xml">
  418. Using format="xml", &lt;junit&gt; fails with a
  419. <code>NoClassDefFoundError</code> if forked.
  420. </a></li>
  421. <li><a href="#xalan-jdk1.5">
  422. <code>&lt;junitreport&gt;</code> doesn't work with JDK 1.5 but
  423. worked fine with JDK 1.4.
  424. </a></li>
  425. </ul>
  426. <h3 class="section">Answers</h3>
  427. <p class="faq">
  428. <a name="latest-version"></a>
  429. Where do I find the latest version of this
  430. document?
  431. </p>
  432. <p>The latest version can always be found at Ant's homepage
  433. <a href="http://ant.apache.org/faq.html">http://ant.apache.org/faq.html</a>.</p>
  434. <p class="faq">
  435. <a name="adding-faqs"></a>
  436. How can I contribute to this FAQ?
  437. </p>
  438. <p>The page you are looking it is generated from
  439. <a href="http://svn.apache.org/repos/asf/ant/core/trunk/xdocs/faq.xml">this</a>
  440. document. If you want to add a new question, please submit
  441. a patch against this document to one of Ant's mailing lists;
  442. hopefully, the structure is self-explanatory.</p>
  443. <p>If you don't know how to create a patch, see the patches
  444. section of <a href="http://jakarta.apache.org/site/source.html">this
  445. page</a>.</p>
  446. <p class="faq">
  447. <a name="creating-faq"></a>
  448. How do you create the HTML version of this
  449. FAQ?
  450. </p>
  451. <p>We use
  452. <a href="http://jakarta.apache.org/velocity/anakia.html">Anakia</a>
  453. to render the HTML version from the original XML file.</p>
  454. <p>The Velocity stylesheets used to process the XML files can
  455. be found in the <code>xdocs/stylesheets</code> subdirectory of
  456. Ant's SVN repository - the build file
  457. <code>docs.xml</code> at the top level of the ant SVN
  458. module (trunk) is used to drive Anakia.</p>
  459. <p>This file assumes that you have the
  460. <code>jakarta-site2</code> CVS module checked out as well, but
  461. if you follow the instruction from Anakia's homepage, you
  462. should get it to work without that. Just make sure all
  463. required jars are in the task's classpath.</p>
  464. <p class="faq">
  465. <a name="what-is-ant"></a>
  466. What is Apache Ant?
  467. </p>
  468. <p> Ant is a Java-based build tool. In theory, it is kind of
  469. like Make, without Make's wrinkles and with the full
  470. portability of pure Java code.</p>
  471. <p class="faq">
  472. <a name="ant-name"></a>
  473. Why do you call it Ant?
  474. </p>
  475. <p>According to Ant's original author, James Duncan
  476. Davidson, the name is an acronym for "Another Neat
  477. Tool".</p>
  478. <p>Later explanations go along the lines of "ants
  479. do an extremely good job at building things", or
  480. "ants are very small and can carry a weight dozens of times
  481. their own" - describing what Ant is intended to
  482. be.</p>
  483. <p class="faq">
  484. <a name="history"></a>
  485. Tell us a little bit about Ant's history.
  486. </p>
  487. <p>Initially, Ant was part of the Tomcat code base, when it was
  488. donated to the Apache Software Foundation. It was
  489. created by James Duncan Davidson, who is also the original
  490. author of Tomcat. Ant was there to build Tomcat, nothing
  491. else.</p>
  492. <p>Soon thereafter, several open source Java projects realized
  493. that Ant could solve the problems they had with Makefiles.
  494. Starting with the projects hosted at Jakarta and the old Java
  495. Apache project, Ant spread like a virus and is now the build
  496. tool of choice for a lot of projects.</p>
  497. <p>In January 2000, Ant was moved to a separate CVS module and
  498. was promoted to a project of its own, independent of
  499. Tomcat, and became Apache Ant.</p>
  500. <p>The first version of Ant that was exposed to a larger audience
  501. was the one that shipped with Tomcat's 3.1 release on 19 April
  502. 2000. This version has later been referred to as Ant
  503. 0.3.1.</p>
  504. <p>The first official release of Ant as a stand-alone product was
  505. Ant 1.1, released on 19 July 2000. The complete release
  506. history:</p>
  507. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  508. <tr>
  509. <th colspan="1" rowspan="1"
  510. valign="top" align="left">
  511. Ant Version
  512. </th>
  513. <th colspan="1" rowspan="1"
  514. valign="top" align="left">
  515. Release Date
  516. </th>
  517. </tr>
  518. <tr>
  519. <td colspan="1" rowspan="1"
  520. valign="top" align="left">
  521. 1.1
  522. </td>
  523. <td colspan="1" rowspan="1"
  524. valign="top" align="left">
  525. 19 July 2000
  526. </td>
  527. </tr>
  528. <tr>
  529. <td colspan="1" rowspan="1"
  530. valign="top" align="left">
  531. 1.2
  532. </td>
  533. <td colspan="1" rowspan="1"
  534. valign="top" align="left">
  535. 24 October 2000
  536. </td>
  537. </tr>
  538. <tr>
  539. <td colspan="1" rowspan="1"
  540. valign="top" align="left">
  541. 1.3
  542. </td>
  543. <td colspan="1" rowspan="1"
  544. valign="top" align="left">
  545. 3 March 2001
  546. </td>
  547. </tr>
  548. <tr>
  549. <td colspan="1" rowspan="1"
  550. valign="top" align="left">
  551. 1.4
  552. </td>
  553. <td colspan="1" rowspan="1"
  554. valign="top" align="left">
  555. 3 September 2001
  556. </td>
  557. </tr>
  558. <tr>
  559. <td colspan="1" rowspan="1"
  560. valign="top" align="left">
  561. 1.4.1
  562. </td>
  563. <td colspan="1" rowspan="1"
  564. valign="top" align="left">
  565. 11 October 2001
  566. </td>
  567. </tr>
  568. <tr>
  569. <td colspan="1" rowspan="1"
  570. valign="top" align="left">
  571. 1.5
  572. </td>
  573. <td colspan="1" rowspan="1"
  574. valign="top" align="left">
  575. 10 July 2002
  576. </td>
  577. </tr>
  578. <tr>
  579. <td colspan="1" rowspan="1"
  580. valign="top" align="left">
  581. 1.5.1
  582. </td>
  583. <td colspan="1" rowspan="1"
  584. valign="top" align="left">
  585. 3 October 2002
  586. </td>
  587. </tr>
  588. <tr>
  589. <td colspan="1" rowspan="1"
  590. valign="top" align="left">
  591. 1.5.2
  592. </td>
  593. <td colspan="1" rowspan="1"
  594. valign="top" align="left">
  595. 3 March 2003
  596. </td>
  597. </tr>
  598. <tr>
  599. <td colspan="1" rowspan="1"
  600. valign="top" align="left">
  601. 1.5.3
  602. </td>
  603. <td colspan="1" rowspan="1"
  604. valign="top" align="left">
  605. 9 April 2003
  606. </td>
  607. </tr>
  608. <tr>
  609. <td colspan="1" rowspan="1"
  610. valign="top" align="left">
  611. 1.5.4
  612. </td>
  613. <td colspan="1" rowspan="1"
  614. valign="top" align="left">
  615. 12 August 2003
  616. </td>
  617. </tr>
  618. <tr>
  619. <td colspan="1" rowspan="1"
  620. valign="top" align="left">
  621. 1.6.0
  622. </td>
  623. <td colspan="1" rowspan="1"
  624. valign="top" align="left">
  625. 18 December 2003
  626. </td>
  627. </tr>
  628. <tr>
  629. <td colspan="1" rowspan="1"
  630. valign="top" align="left">
  631. 1.6.1
  632. </td>
  633. <td colspan="1" rowspan="1"
  634. valign="top" align="left">
  635. 12 February 2004
  636. </td>
  637. </tr>
  638. <tr>
  639. <td colspan="1" rowspan="1"
  640. valign="top" align="left">
  641. 1.6.2
  642. </td>
  643. <td colspan="1" rowspan="1"
  644. valign="top" align="left">
  645. 16 July 2004
  646. </td>
  647. </tr>
  648. <tr>
  649. <td colspan="1" rowspan="1"
  650. valign="top" align="left">
  651. 1.6.3
  652. </td>
  653. <td colspan="1" rowspan="1"
  654. valign="top" align="left">
  655. 28 April 2005
  656. </td>
  657. </tr>
  658. <tr>
  659. <td colspan="1" rowspan="1"
  660. valign="top" align="left">
  661. 1.6.4
  662. </td>
  663. <td colspan="1" rowspan="1"
  664. valign="top" align="left">
  665. 19 May 2005
  666. </td>
  667. </tr>
  668. <tr>
  669. <td colspan="1" rowspan="1"
  670. valign="top" align="left">
  671. 1.6.5
  672. </td>
  673. <td colspan="1" rowspan="1"
  674. valign="top" align="left">
  675. 2 June 2005
  676. </td>
  677. </tr>
  678. <tr>
  679. <td colspan="1" rowspan="1"
  680. valign="top" align="left">
  681. 1.7.0
  682. </td>
  683. <td colspan="1" rowspan="1"
  684. valign="top" align="left">
  685. 19 December 2006
  686. </td>
  687. </tr>
  688. <tr>
  689. <td colspan="1" rowspan="1"
  690. valign="top" align="left">
  691. 1.7.1
  692. </td>
  693. <td colspan="1" rowspan="1"
  694. valign="top" align="left">
  695. 27 June 2008
  696. </td>
  697. </tr>
  698. </table>
  699. <p class="faq">
  700. <a name="java-version"></a>
  701. Which version of Java is required to run
  702. Ant?
  703. </p>
  704. <p>You will need Java installed on your system, version 1.3 or
  705. later required, 1.5 or later strongly recommended. The later
  706. the version of Java, the more Ant tasks you get.</p>
  707. <p>If only the JRE is present but not a full JDK then many
  708. tasks will not work.</p>
  709. <p>Ant 1.6.* works with jdk 1.2 and higher, Ant 1.1 to Ant
  710. 1.5.* work with jdk 1.1 and higher.</p>
  711. <p class="faq">
  712. <a name="no-gnu-tar"></a>
  713. I get checksum errors when I try to extract the
  714. <code>tar.gz</code> distribution file. Why?
  715. </p>
  716. <p>Ant's distribution contains file names that are longer
  717. than 100 characters, which is not supported by the standard
  718. tar file format. Several different implementations of tar use
  719. different and incompatible ways to work around this
  720. restriction.</p>
  721. <p>Ant's &lt;tar&gt; task can create tar archives that use
  722. the GNU tar extension, and this has been used when putting
  723. together the distribution. If you are using a different
  724. version of tar (for example, the one shipping with Solaris),
  725. you cannot use it to extract the archive.</p>
  726. <p>The solution is to either install GNU tar, which can be
  727. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>,
  728. or use the zip archive instead (you can extract it using
  729. <code>jar xf</code>).</p>
  730. <p class="faq">
  731. <a name="RedHat_ES_3"></a>
  732. How do you get ant-1.6.x (or any version later than
  733. 1.5.2) to work on on RedHat ES 3?
  734. </p>
  735. <p>Redhat ES 3.0 comes installed with ant 1.5.2. Even if you
  736. have your PATH and ANT_HOME variables set correctly to a later
  737. version of ant, you will always be forced to use the
  738. preinstalled version.</p>
  739. <p>To use a later version of ant on this OS you could do the
  740. following:</p>
  741. <pre class="code">
  742. $ ant -version
  743. Apache Ant version 1.5.2-23 compiled on November 12 2003
  744. $ su -
  745. # rpm -e ant ant-libs
  746. # exit
  747. $ hash -r
  748. $ ant -version
  749. Apache Ant version 1.6.2 compiled on July 16 2004
  750. </pre>
  751. <p class="faq">
  752. <a name="implement-os-specific-configuration"></a>
  753. How do I realize os--specific configurations?
  754. </p>
  755. <p>The core idea is using property files which name accords to the
  756. os-name. Then simply use the build-in property <tt>os.name</tt>.</p>
  757. <p>For better use you should also provide a file with default values.
  758. But be careful with the correct os-names. For test simply &lt;echo&gt;
  759. the ${os.name} on all machines and you can be sure to use the right
  760. file names.</p>
  761. <pre class="code">
  762. &lt;property file=&quot;${os.name}.properties&quot;/&gt;
  763. &lt;property file=&quot;default.properties&quot;/&gt;
  764. </pre>
  765. <p class="faq">
  766. <a name="adding-external-tasks"></a>
  767. How do I add an external task that I've written to the
  768. page "External Tools and Tasks"?
  769. </p>
  770. <p>Join and post a message to the dev or user mailing
  771. list (one list is enough), including the following
  772. information:</p>
  773. <ul>
  774. <li>the name of the task/tool</li>
  775. <li>a short description of the task/tool</li>
  776. <li>a Compatibility: entry stating with which version(s) of
  777. Ant the tool/task is compatible to</li>
  778. <li>a URL: entry linking to the main page of the tool/task</li>
  779. <li>a Contact: entry containing the email address or the URL
  780. of a webpage for the person or list to contact for issues
  781. related to the tool/task. <strong>Note that we'll add a
  782. link on the page, so any email address added there is not
  783. obfuscated and can (and probably will) be abused by robots
  784. harvesting websites for addresses to spam.</strong></li>
  785. <li>a License: entry containing the type of license for the
  786. tool/task</li>
  787. </ul>
  788. <p>The preferred format for this information is a patch to <a href="http://svn.apache.org/repos/asf/ant/core/trunk/xdocs/external.xml">this</a>
  789. document.</p>
  790. <p>If you have written something bigger than a 'simple plugin' to Ant it
  791. may be better to add the link to <a href="projects.html">projects.html</a>.
  792. The procedure to add it is the same. The file to patch is <a href="http://svn.apache.org/repos/asf/ant/core/trunk/xdocs/projects.xml">this</a>
  793. document. The syntax of that file is the same.</p>
  794. <p class="faq">
  795. <a name="create-extensions"></a>
  796. How do I create new tasks?
  797. </p>
  798. <p>Apart from a lot of information on using Ant, the
  799. <a href="manual/index.html">Manual</a> also contains information
  800. on how to extend Ant with new tasks. This information
  801. can be found under "Developing with Ant".</p>
  802. <p>Chances are that someone else already created the task you
  803. want to create, it may be wise to see
  804. <a href="external.html">External Tools and Tasks</a> and
  805. <a href="projects.html">Related Projects</a> first.</p>
  806. <p class="faq">
  807. <a name="passing-cli-args"></a>
  808. How do I pass parameters from the command line to my
  809. build file?
  810. </p>
  811. <p>Use properties. Using <code>ant
  812. -D<em>name</em>=<em>value</em></code> lets you define values for
  813. properties on the Ant command line. These properties can then be
  814. used within your build file as
  815. any normal property: <code>${<em>name</em>}</code> will put in
  816. <code><em>value</em></code>.</p>
  817. <p class="faq">
  818. <a name="jikes-switches"></a>
  819. How can I use Jikes-specific command-line
  820. switches?
  821. </p>
  822. <p>A couple of switches are supported via "magic"
  823. properties:</p>
  824. <table class="ForrestTable" cellspacing="1" cellpadding="4">
  825. <tr>
  826. <th colspan="1" rowspan="1"
  827. valign="top" align="left">
  828. switch
  829. </th>
  830. <th colspan="1" rowspan="1"
  831. valign="top" align="left">
  832. property
  833. </th>
  834. <th colspan="1" rowspan="1"
  835. valign="top" align="left">
  836. default
  837. </th>
  838. </tr>
  839. <tr>
  840. <td colspan="1" rowspan="1"
  841. valign="top" align="left">
  842. +E
  843. </td>
  844. <td colspan="1" rowspan="1"
  845. valign="top" align="left">
  846. build.compiler.emacs
  847. </td>
  848. <td colspan="1" rowspan="1"
  849. valign="top" align="left">
  850. false == not set
  851. </td>
  852. </tr>
  853. <tr>
  854. <td colspan="1" rowspan="1"
  855. valign="top" align="left">
  856. +P
  857. </td>
  858. <td colspan="1" rowspan="1"
  859. valign="top" align="left">
  860. build.compiler.pedantic
  861. </td>
  862. <td colspan="1" rowspan="1"
  863. valign="top" align="left">
  864. false == not set
  865. </td>
  866. </tr>
  867. <tr>
  868. <td colspan="1" rowspan="1"
  869. valign="top" align="left">
  870. +F
  871. </td>
  872. <td colspan="1" rowspan="1"
  873. valign="top" align="left">
  874. build.compiler.fulldepend
  875. </td>
  876. <td colspan="1" rowspan="1"
  877. valign="top" align="left">
  878. false == not set
  879. </td>
  880. </tr>
  881. <tr>
  882. <td colspan="1" rowspan="1"
  883. valign="top" align="left">
  884. <strong>(Only for Ant &lt; 1.4; replaced by the
  885. <code><strong>nowarn</strong></code>
  886. attribute of the <code><strong>&lt;javac&gt;</strong></code>
  887. task after that.)</strong><br />-nowarn
  888. </td>
  889. <td colspan="1" rowspan="1"
  890. valign="top" align="left">
  891. build.compiler.warnings
  892. </td>
  893. <td colspan="1" rowspan="1"
  894. valign="top" align="left">
  895. true == not set
  896. </td>
  897. </tr>
  898. </table>
  899. <p>With Ant &gt;= 1.5, you can also use nested
  900. <code>&lt;compilerarg&gt;</code> elements with the
  901. <code>&lt;javac&gt;</code> task.</p>
  902. <p class="faq">
  903. <a name="shell-redirect-1"></a>
  904. How do I include a &lt; character in my command-line arguments?
  905. </p>
  906. <p>The short answer is "Use: <code>&amp;lt;</code>".</p>
  907. <p>The long answer is that this probably won't do what you
  908. want anyway (see <a href="#shell-redirect-2">the next
  909. section</a>).</p>
  910. <p class="faq">
  911. <a name="shell-redirect-2"></a>
  912. How do I redirect standard input or standard output
  913. in the <code>&lt;exec&gt;</code> task?
  914. </p>
  915. <p>Say you want to redirect the standard output stream of the
  916. <code>m4</code> command to write to a file, something
  917. like:</p>
  918. <pre class="code">
  919. shell-prompt&gt; m4 foo.m4 &gt; foo
  920. </pre>
  921. <p>and try to translate it into</p>
  922. <pre class="code">
  923. &lt;exec executable=&quot;m4&quot;&gt;
  924. &lt;arg value=&quot;foo.m4&quot;/&gt;
  925. &lt;arg value=&quot;&amp;gt;&quot;/&gt;
  926. &lt;arg value=&quot;foo&quot;/&gt;
  927. &lt;/exec&gt;
  928. </pre>
  929. <p>This will not do what you expect. The output redirection is
  930. performed by your shell, not the command itself, so this
  931. should read:</p>
  932. <pre class="code">
  933. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  934. &lt;arg value=&quot;-c&quot; /&gt;
  935. &lt;arg value=&quot;m4 foo.m4 &amp;gt; foo&quot; /&gt;
  936. &lt;/exec&gt;
  937. </pre>
  938. <p>Note that you must use the <code>value</code> attribute of
  939. <code>&lt;arg&gt;</code> in the last element, in order to have
  940. the command passed as a single, quoted argument. Alternatively,
  941. you can use:</p>
  942. <pre class="code">
  943. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  944. &lt;arg line='-c &quot;m4 foo.m4 &amp;gt; foo&quot;'/&gt;
  945. &lt;/exec&gt;
  946. </pre>
  947. <p>Note the double-quotes nested inside the single-quotes.</p>
  948. <p class="faq">
  949. <a name="batch-shell-execute"></a>
  950. How do I execute a batch file or shell script from Ant?
  951. </p>
  952. <p>On native Unix systems, you should be able to run shell scripts
  953. directly. On systems running a Unix-type shell (for example, Cygwin
  954. on Windows) execute the (command) shell instead - <code>cmd</code>
  955. for batch files, <code>sh</code> for shell scripts - then pass the
  956. batch file or shell script (plus any arguments to the script)
  957. as a single command, using the <code>/c</code> or
  958. <code>-c</code> switch, respectively. See
  959. <a href="#shell-redirect-2">the above section</a>
  960. for example <code>&lt;exec&gt;</code> tasks
  961. executing <code>sh</code>. For batch files, use something like:</p>
  962. <pre class="code">
  963. &lt;exec dir=&quot;.&quot; executable=&quot;cmd&quot; os=&quot;Windows NT&quot;&gt;
  964. &lt;arg line=&quot;/c test.bat&quot;/&gt;
  965. &lt;/exec&gt;
  966. </pre>
  967. <p class="faq">
  968. <a name="multi-conditions"></a>
  969. I want to execute a particular target only if
  970. multiple conditions are true.
  971. </p>
  972. <p>There are actually several answers to this question.</p>
  973. <p>If you have only one set and one unset property to test,
  974. you can specify both an <code>if</code> and an <code>unless</code>
  975. attribute for the target, and they will act as if they
  976. are "anded" together.</p>
  977. <p>If you are using a version of Ant 1.3 or earlier, the
  978. way to work with all other cases is to chain targets together
  979. to determine the specific state you want to test for.</p>
  980. <p>To see how this works, assume you have three properties:
  981. <code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
  982. You want to test that <code>prop1</code> and <code>prop2</code>
  983. are set, and that <code>prop3</code> is not. If the condition
  984. holds true you want to echo "yes".</p>
  985. <p>Here is the implementation in Ant 1.3 and earlier:</p>
  986. <pre class="code">
  987. &lt;target name=&quot;cond&quot; depends=&quot;cond-if&quot;/&gt;
  988. &lt;target name=&quot;cond-if&quot; if=&quot;prop1&quot;&gt;
  989. &lt;antcall target=&quot;cond-if-2&quot;/&gt;
  990. &lt;/target&gt;
  991. &lt;target name=&quot;cond-if-2&quot; if=&quot;prop2&quot;&gt;
  992. &lt;antcall target=&quot;cond-if-3&quot;/&gt;
  993. &lt;/target&gt;
  994. &lt;target name=&quot;cond-if-3&quot; unless=&quot;prop3&quot;&gt;
  995. &lt;echo message=&quot;yes&quot;/&gt;
  996. &lt;/target&gt;
  997. </pre>
  998. <p>Note: <code>&lt;antcall&gt;</code> tasks do <em>not</em> pass
  999. property changes back up to the environment they were called
  1000. from, so you wouldn't be able to, for example, set a
  1001. <code>result</code> property in the <code>cond-if-3</code> target,
  1002. then do
  1003. <code>&lt;echo message="result is ${result}"/&gt;</code>
  1004. in the <code>cond</code> target.</p>
  1005. <p>Starting with Ant 1.4, you can use the
  1006. <code>&lt;condition&gt;</code> task.</p>
  1007. <pre class="code">
  1008. &lt;target name=&quot;cond&quot; depends=&quot;cond-if,cond-else&quot;/&gt;
  1009. &lt;target name=&quot;check-cond&quot;&gt;
  1010. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1011. &lt;and&gt;
  1012. &lt;not&gt;
  1013. &lt;equals arg1=&quot;${prop1}&quot; arg2=&quot;$${prop1}&quot; /&gt;
  1014. &lt;/not&gt;
  1015. &lt;not&gt;
  1016. &lt;equals arg1=&quot;${prop2}&quot; arg2=&quot;$${prop2}&quot; /&gt;
  1017. &lt;/not&gt;
  1018. &lt;equals arg1=&quot;${prop3}&quot; arg2=&quot;$${prop3}&quot; /&gt;
  1019. &lt;/and&gt;
  1020. &lt;/condition&gt;
  1021. &lt;/target&gt;
  1022. &lt;target name=&quot;cond-if&quot; depends=&quot;check-cond&quot; if=&quot;cond-is-true&quot;&gt;
  1023. &lt;echo message=&quot;yes&quot;/&gt;
  1024. &lt;/target&gt;
  1025. &lt;target name=&quot;cond-else&quot; depends=&quot;check-cond&quot; unless=&quot;cond-is-true&quot;&gt;
  1026. &lt;echo message=&quot;no&quot;/&gt;
  1027. &lt;/target&gt;
  1028. </pre>
  1029. <p>This version takes advantage of two things:</p>
  1030. <ul>
  1031. <li>If a property <code>a</code> has not been set,
  1032. <code>${a}</code> will evaluate to <code>${a}</code>.</li>
  1033. <li>To get a literal <code>$</code> in Ant, you have to
  1034. escape it with another <code>$</code> - this will also break
  1035. the special treatment of the <code>${</code> sequence.</li>
  1036. </ul>
  1037. <p>Because testing for a literal <code>${property}</code> string
  1038. isn't all that readable or easy to understand,
  1039. post-1.4.1 Ant introduces the <code>&lt;isset&gt;</code> element
  1040. to the <code>&lt;condition&gt;</code> task.</p>
  1041. <p>Here is the previous example done using
  1042. <code>&lt;isset&gt;</code>:</p>
  1043. <pre class="code">
  1044. &lt;target name=&quot;check-cond&quot;&gt;
  1045. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1046. &lt;and&gt;
  1047. &lt;isset property=&quot;prop1&quot;/&gt;
  1048. &lt;isset property=&quot;prop2&quot;/&gt;
  1049. &lt;not&gt;
  1050. &lt;isset property=&quot;prop3&quot;/&gt;
  1051. &lt;/not&gt;
  1052. &lt;/and&gt;
  1053. &lt;/condition&gt;
  1054. &lt;/target&gt;
  1055. </pre>
  1056. <p>The last option is to use a scripting language to set the
  1057. properties. This can be particularly handy when you need much
  1058. finer control than the simple conditions shown here but, of
  1059. course, comes with the overhead of adding JAR files to support
  1060. the language, to say nothing of the added maintenance in requiring
  1061. two languages to implement a single system. See the
  1062. <a href="manual/OptionalTasks/script.html">
  1063. <code>&lt;script&gt;</code> task documentation</a> for more
  1064. details.</p>
  1065. <p class="faq">
  1066. <a name="encoding"></a>
  1067. How can I include national characters like German
  1068. umlauts in my build file?
  1069. </p>
  1070. <p>You need to tell the XML parser which character encoding
  1071. your build file uses, this is done inside the <a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd">XML
  1072. declaration</a>.</p>
  1073. <p>By default the parser assumes you are using the UTF-8
  1074. encoding instead of your platform's default. For most Western
  1075. European countries you should set the encoding to
  1076. <code>ISO-8859-1</code>. To do so, make the very first line
  1077. of you build file read like</p>
  1078. <pre class="code">
  1079. &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
  1080. </pre>
  1081. <p class="faq">
  1082. <a name="use-zip-instead-of-jar"></a>
  1083. How do I use <code>jar</code>'s <code>M</code> switch?
  1084. I don't want a MANIFEST.
  1085. </p>
  1086. <p>A JAR archive is a ZIP file, so if you don't want a
  1087. MANIFEST you can simply use <code>&lt;zip&gt;</code>.</p>
  1088. <p>If your file names contain national characters you should
  1089. know that Sun's <code>jar</code> utility like Ant's
  1090. <code>&lt;jar&gt;</code> uses UTF-8 to encode their names while
  1091. <code>&lt;zip&gt;</code> uses your platforms default encoding.
  1092. Use the encoding attribute of <code>&lt;zip&gt;</code> if
  1093. necessary.</p>
  1094. <p class="faq">
  1095. <a name="propertyvalue-as-name-for-property"></a>
  1096. How can I do something like <code>&lt;property name="prop"
  1097. value="${${anotherprop}}"/&gt;</code> (double expanding the property)?
  1098. </p>
  1099. <p>Without any external help you can not.</p>
  1100. <p>With &lt;script/&gt;, which needs external libraries, you can do</p>
  1101. <pre class="code">
  1102. &lt;script language=&quot;javascript&quot;&gt;
  1103. propname = project.getProperty(&quot;anotherprop&quot;);
  1104. project.setNewProperty(&quot;prop&quot;, propname);
  1105. &lt;/script&gt;
  1106. </pre>
  1107. <p>With AntContrib (external task library) you can do <code>
  1108. &lt;propertycopy name="prop" from="${anotherprop}"/&gt;</code>.</p>
  1109. <p>With Ant 1.6 you can simulate the AntContribs &lt;propertycopy&gt;
  1110. and avoid the need of an external library:</p>
  1111. <pre class="code">
  1112. &lt;macrodef name=&quot;propertycopy&quot;&gt;
  1113. &lt;attribute name=&quot;name&quot;/&gt;
  1114. &lt;attribute name=&quot;from&quot;/&gt;
  1115. &lt;sequential&gt;
  1116. &lt;property name=&quot;@{name}&quot; value=&quot;${@{from}}&quot;/&gt;
  1117. &lt;/sequential&gt;
  1118. &lt;/macrodef&gt;
  1119. </pre>
  1120. <p class="faq">
  1121. <a name="delete-directory-children-only"></a>
  1122. How can I delete everything beneath a particular directory,
  1123. preserving the directory itself?
  1124. </p>
  1125. <p>Most users who go down this path have no problem figuring out that
  1126. <code>&lt;delete includeemptydirs="true" /&gt;</code> will help them. The
  1127. seemingly tricky part is preserving the base directory itself,
  1128. which Ant includes in the directory scan. Fortunately the answer is simple:
  1129. </p>
  1130. <pre class="code">
  1131. &lt;delete includeemptydirs=&quot;true&quot;&gt;
  1132. &lt;fileset dir=&quot;dirtokeep&quot; includes=&quot;**/*&quot; /&gt;
  1133. &lt;/delete&gt;
  1134. </pre>
  1135. <p class="faq">
  1136. <a name="general-advice"></a>
  1137. General Advice
  1138. </p>
  1139. <p>There are many reasons why Ant doesn't behave as
  1140. expected, not all of them are due to Ant bugs. See our <a href="problems.html">Having Problems?</a> page for hints that
  1141. may help pinning down the reasons for your problem.</p>
  1142. <p class="faq">
  1143. <a name="always-recompiles"></a>
  1144. Why does Ant always recompile all my Java files?
  1145. </p>
  1146. <p>In order to find out which files should be compiled, Ant
  1147. compares the timestamps of the source files to those of the
  1148. resulting <code>.class</code> files. Opening all source files
  1149. to find out which package they belong to would be very
  1150. inefficient. Instead, Ant expects you to place your
  1151. source files in a directory hierarchy that mirrors your
  1152. package hierarchy and to point Ant to the root of this
  1153. directory tree with the <code>srcdir</code> attribute.</p>
  1154. <p>Say you have <code>&lt;javac srcdir="src"
  1155. destdir="dest"/&gt;</code>. If Ant finds a file
  1156. <code>src/a/b/C.java</code>, it expects it to be in package
  1157. <code>a.b</code> so that the resulting <code>.class</code>
  1158. file is going to be <code>dest/a/b/C.class</code>.</p>
  1159. <p>If your source-tree directory structure does not match your
  1160. package structure, Ant's heuristic won't work, and
  1161. it will recompile classes that are up-to-date. Ant is not the
  1162. only tool that expects a source-tree layout like this.</p>
  1163. <p>If you have Java source files that aren't declared to
  1164. be part of any package, you can still use the <code>&lt;javac&gt;</code>
  1165. task to compile these files correctly - just set the
  1166. <code>srcdir</code> and <code>destdir</code> attributes to
  1167. the actual directory the source
  1168. files live in and the directory the class files should go into,
  1169. respectively.</p>
  1170. <p class="faq">
  1171. <a name="defaultexcludes"></a>
  1172. I've used a <code>&lt;delete&gt;</code> task to
  1173. delete unwanted SourceSafe control files (CVS files, editor
  1174. backup files, etc.), but it doesn't seem to work; the files
  1175. never get deleted. What's wrong?
  1176. </p>
  1177. <p>This is probably happening because, by default, Ant excludes
  1178. SourceSafe control files (<code>vssver.scc</code>) and certain other
  1179. files from FileSets.</p>
  1180. <p>Here's what you probably did:</p>
  1181. <pre class="code">
  1182. &lt;delete&gt;
  1183. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  1184. &lt;/delete&gt;
  1185. </pre>
  1186. <p>You need to switch off the default exclusions,
  1187. and it will work:</p>
  1188. <pre class="code">
  1189. &lt;delete&gt;
  1190. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  1191. defaultexcludes=&quot;no&quot;/&gt;
  1192. &lt;/delete&gt;
  1193. </pre>
  1194. <p>For a complete listing of the patterns that are excluded
  1195. by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
  1196. manual</a>.</p>
  1197. <p class="faq">
  1198. <a name="stop-dependency"></a>
  1199. I have a target I want to skip if a property is set,
  1200. so I have <code>unless="property"</code> as an attribute
  1201. of the target, but all the targets this target
  1202. depends on are still executed. Why?
  1203. </p>
  1204. <p>The list of dependencies is generated by Ant before any of the
  1205. targets are run. This allows dependent targets, such as an
  1206. <code>init</code> target, to set properties that can control the
  1207. execution of the targets higher in the dependency graph. This
  1208. is a good thing.</p>
  1209. <p>However, when your dependencies break down the
  1210. higher-level task
  1211. into several smaller steps, this behaviour becomes
  1212. counter-intuitive. There are a couple of solutions available:
  1213. </p>
  1214. <ol>
  1215. <li>Put the same condition on each of the dependent targets.</li>
  1216. <li>Execute the steps using <code>&lt;antcall&gt;</code>,
  1217. instead of specifying them inside the <code>depends</code>
  1218. attribute.</li>
  1219. </ol>
  1220. <p class="faq">
  1221. <a name="include-order"></a>
  1222. In my <code>&lt;fileset&gt;</code>, I've put in an
  1223. <code>&lt;exclude&gt;</code> of all files followed by an
  1224. <code>&lt;include&gt;</code> of just the files I want, but it
  1225. isn't giving me any files at all. What's wrong?
  1226. </p>
  1227. <p>The order of the <code>&lt;include&gt;</code> and
  1228. <code>&lt;exclude&gt;</code> tags within a <code>&lt;fileset&gt;</code>
  1229. is ignored when the FileSet is created. Instead, all of the
  1230. <code>&lt;include&gt;</code> elements are processed together,
  1231. followed by all of the <code>&lt;exclude&gt;</code>
  1232. elements. This means that the <code>&lt;exclude&gt;</code>
  1233. elements only apply to the file list produced by the
  1234. <code>&lt;include&gt;</code> elements.</p>
  1235. <p>To get the files you want, focus on just the
  1236. <code>&lt;include&gt;</code> patterns that would be necessary
  1237. to get them. If you find you need to trim the list that the
  1238. <code>&lt;include&gt;</code> elements produce, then use
  1239. <code>&lt;exclude&gt;</code> elements.</p>
  1240. <p class="faq">
  1241. <a name="properties-not-trimmed"></a>
  1242. <code>ant</code> failed to build my program via javac
  1243. even when I put the needed jars in an external
  1244. <code>build.properties</code> file and reference them by
  1245. <code>pathelement</code> or <code>classpath refid</code>.
  1246. </p>
  1247. <p>When <code>ant</code> loads properties from an external
  1248. file it doesn't touch the value of properties, trailing blanks
  1249. will not be trimmed for example.</p>
  1250. <p>If the value represents a file path, like a jar needed to
  1251. compile, the task which requires the value, javac for example
  1252. would fail to compile since it can't find the file due to
  1253. trailing spaces.</p>
  1254. <p class="faq">
  1255. <a name="winzip-lies"></a>
  1256. Ant creates WAR files with a lower-case
  1257. <code>web-inf</code> or JAR files with a lower-case
  1258. <code>meta-inf</code> directory.
  1259. </p>
  1260. <p>No it doesn't.</p>
  1261. <p>You may have seen these lower-case directory names in
  1262. WinZIP, but WinZIP is trying to be helpful (and fails). If
  1263. WinZIP encounters a filename that is all upper-case, it
  1264. assumes it has come from an old DOS box and changes the case to
  1265. all lower-case for you.</p>
  1266. <p>If you extract (or just check) the archive with jar, you
  1267. will see that the names have the correct case.</p>
  1268. <p>With WinZIP (version 8.1 at least), this can be corrected in the
  1269. configuration. In the Options/Configuration menu, in the View tab, General
  1270. section, check the "Allow all upper case files names" box. The META-INF and
  1271. WEB-INF will look correct.</p>
  1272. <p class="faq">
  1273. <a name="NoClassDefFoundError"></a>
  1274. I installed Ant 1.6.x and now get
  1275. <code>Exception in thread "main" java.lang.NoClassDefFoundError:
  1276. </code>
  1277. </p>
  1278. <p>
  1279. The cause of this is that there is an old version of ant somewhere in the
  1280. class path or configuration.
  1281. </p>
  1282. <p>
  1283. A version of this problem happens with jars that are in the classpath
  1284. that include an embedded copy of ant classes.
  1285. An example of this is some copies of weblogic.jar.
  1286. </p>
  1287. <p>
  1288. One can check if this is the case by doing (on unix/sh):
  1289. <code><pre>
  1290. unset CLASSPATH
  1291. ant -version
  1292. </pre>
  1293. </code>
  1294. </p>
  1295. <p class="faq">
  1296. <a name="InstantiationException"></a>
  1297. I installed Ant 1.6.x and now get
  1298. <code>java.lang.InstantiationException: org.apache.tools.ant.Main</code>
  1299. </p>
  1300. <p>
  1301. The cause of this is that there is an old version of ant somewhere in the
  1302. class path or configuration.
  1303. </p>
  1304. <p>
  1305. A version of this problem may be seen on some linux systems.
  1306. Some linux systems (Fedora Core 2 for example), comes with a version
  1307. of ant pre-installed. There is a configuration file called
  1308. <code>/etc/ant.conf</code> which if present, the ant shell
  1309. script will 'dot' include. On Fedora Core 2, the /etc/ant.conf
  1310. file resets the <code>ANT_HOME</code> environment variable to
  1311. <code>/usr/share/ant</code>. This causes the problem that
  1312. an old version of ant (1.5.x in this cause) will be used
  1313. with a new version of the ant script file.
  1314. </p>
  1315. <p>
  1316. One can check if this is the case by doing
  1317. <code>ant --noconfig -version</code>.
  1318. </p>
  1319. <p class="faq">
  1320. <a name="mangled-manifest"></a>
  1321. Whenever I use the Ant jar or manifest related tasks, long lines in
  1322. my manifest are wrapped at 70 characters and the resulting jar does
  1323. not work in my application server. Why does Ant do this?
  1324. </p>
  1325. <p>
  1326. Ant implements the Java
  1327. <a href="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html">Jar
  1328. file specification</a>. Please refer to the notes section where it
  1329. discusses the maximum allowable length of a line and the concept of
  1330. continuation characters.
  1331. </p>
  1332. <p>
  1333. If a jar file produced by Ant does not work in your appserver, and
  1334. that failure is due to the wrapped manifest, then you need
  1335. to consult your appserver provider, as it is a bug in their
  1336. appserver. Far more likely, however, is a problem in your
  1337. specification of your classpath. It is not Ant's wrapping of your
  1338. classpath that is the problem.
  1339. </p>
  1340. <p>
  1341. Do not raise a bug about this issue until you have checked to ensure
  1342. that the problem is not due to your classpath specification.
  1343. </p>
  1344. <p class="faq">
  1345. <a name="integration"></a>
  1346. Is Ant supported by my IDE/Editor?
  1347. </p>
  1348. <p>See the <a href="external.html#IDE and Editor Integration">section
  1349. on IDE integration</a> on our External Tools and Tasks page.</p>
  1350. <p class="faq">
  1351. <a name="emacs-mode"></a>
  1352. Why doesn't (X)Emacs/vi/MacOS X's project builder
  1353. correctly parse the error messages generated by Ant?
  1354. </p>
  1355. <p>Ant adds a "banner" with the name of the current
  1356. task in front of all logging messages - and there are no built-in
  1357. regular expressions in your editor that would account for
  1358. this.</p>
  1359. <p>You can disable this banner by invoking Ant with the
  1360. <code>-emacs</code> switch. To make Ant autodetect
  1361. Emacs' compile mode, put this into your
  1362. <code>.antrc</code> (contributed by Ville Skytt).</p>
  1363. <pre class="code">
  1364. # Detect (X)Emacs compile mode
  1365. if [ &quot;$EMACS&quot; = &quot;t&quot; ] ; then
  1366. ANT_ARGS=&quot;$ANT_ARGS -emacs&quot;
  1367. ANT_OPTS=&quot;$ANT_OPTS -Dbuild.compiler.emacs=true&quot;
  1368. fi
  1369. </pre>
  1370. <p>Alternatively, you can add the following snippet to your
  1371. <code>.emacs</code> to make Emacs understand Ant's
  1372. output.</p>
  1373. <pre class="code">
  1374. (require 'compile)
  1375. (setq compilation-error-regexp-alist
  1376. (append (list
  1377. ;; works for jikes
  1378. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  1379. ;; works for javac
  1380. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  1381. compilation-error-regexp-alist))
  1382. </pre>
  1383. <p>Yet another alternative that preserves most of Ant's
  1384. formatting is to pipe Ant's output through the following Perl
  1385. script by Dirk-Willem van Gulik:</p>
  1386. <pre class="code">
  1387. #!/usr/bin/perl
  1388. #
  1389. # May 2001 dirkx@apache.org - remove any
  1390. # [foo] lines from the output; keeping
  1391. # spacing more or less there.
  1392. #
  1393. $|=1;
  1394. while(&lt;STDIN&gt;) {
  1395. if (s/^(\s+)\[(\w+)\]//) {
  1396. if ($2 ne $last) {
  1397. print &quot;$1\[$2\]&quot;;
  1398. $s = ' ' x length($2);
  1399. } else {
  1400. print &quot;$1 $s &quot;;
  1401. };
  1402. $last = $2;
  1403. };
  1404. print;
  1405. };
  1406. </pre>
  1407. <p class="faq">
  1408. <a name="dtd"></a>
  1409. Is there a DTD that I can use to validate my build
  1410. files?
  1411. </p>
  1412. <p>An incomplete DTD can be created by the
  1413. <code>&lt;antstructure&gt;</code> task - but this one
  1414. has a few problems:</p>
  1415. <ul>
  1416. <li>It doesn't know about required attributes. Only
  1417. manual tweaking of this file can help here.</li>
  1418. <li>It is not complete - if you add new tasks via
  1419. <code>&lt;taskdef&gt;</code> it won't know about it. See
  1420. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  1421. page</a> by Michel Casabianca for a solution to this
  1422. problem. Note that the DTD you can download at this page
  1423. is based on Ant 0.3.1.</li>
  1424. <li>It may even be an invalid DTD. As Ant allows tasks
  1425. writers to define arbitrary elements, name collisions will
  1426. happen quite frequently - if your version of Ant contains
  1427. the optional <code>&lt;test&gt;</code> and
  1428. <code>&lt;junit&gt;</code> tasks, there are two XML
  1429. elements named <code>test</code> (the task and the nested child
  1430. element of <code>&lt;junit&gt;</code>) with different attribute
  1431. lists. This problem cannot be solved; DTDs don't give a
  1432. syntax rich enough to support this.</li>
  1433. </ul>
  1434. <p class="faq">
  1435. <a name="xml-entity-include"></a>
  1436. How do I include an XML snippet in my build file?
  1437. </p>
  1438. <p>You can use XML's way of including external files and let
  1439. the parser do the job for Ant:</p>
  1440. <pre class="code">
  1441. &lt;?xml version=&quot;1.0&quot;?&gt;
  1442. &lt;!DOCTYPE project [
  1443. &lt;!ENTITY common SYSTEM &quot;common.xml&quot;&gt;
  1444. ]&gt;
  1445. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1446. &lt;target name=&quot;setup&quot;&gt;
  1447. ...
  1448. &lt;/target&gt;
  1449. &amp;common;
  1450. ...
  1451. &lt;/project&gt;
  1452. </pre>
  1453. <p>will literally include the contents of <code>common.xml</code> where
  1454. you've placed the <code>&amp;common;</code> entity.</p>
  1455. <p>(The filename <code>common.xml</code> in this example is resolved
  1456. relative to the containing XML file by the XML parser. You may also use
  1457. an absolute <code>file:</code> protocol URI.)</p>
  1458. <p>In combination with a DTD, this would look like this:</p>
  1459. <pre class="code">
  1460. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;ant.dtd&quot; [
  1461. &lt;!ENTITY include SYSTEM &quot;header.xml&quot;&gt;
  1462. ]&gt;
  1463. </pre>
  1464. <p>Starting with Ant 1.6, there is a new
  1465. <code>&lt;import&gt;</code> task that can (also) be used to
  1466. include build file fragments. Unlike the snippets used with
  1467. entity includes, the referenced files have to be complete Ant
  1468. build files, though.</p>
  1469. <p>The example above would become:</p>
  1470. <pre class="code">
  1471. &lt;?xml version=&quot;1.0&quot;?&gt;
  1472. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1473. &lt;target name=&quot;setup&quot;&gt;
  1474. ...
  1475. &lt;/target&gt;
  1476. &lt;import file=&quot;./common.xml&quot;/&gt;
  1477. ...
  1478. &lt;/project&gt;
  1479. </pre>
  1480. <p>Unlike entity includes, <code>&lt;import&gt;</code> will
  1481. let you use Ant properties in the file name.</p>
  1482. <p class="faq">
  1483. <a name="mail-logger"></a>
  1484. How do I send an email with the result of my build
  1485. process?
  1486. </p>
  1487. <p>If you are using a nightly build of Ant 1.5 after
  1488. 2001-12-14, you can use the built-in MailLogger:</p>
  1489. <pre class="code">
  1490. ant -logger org.apache.tools.ant.listener.MailLogger
  1491. </pre>
  1492. <p>See the <a href="http://svn.apache.org/repos/asf/ant/core/trunk/docs/manual/listeners.html">Listeners
  1493. &amp; Loggers</a> documentation for details on the properties
  1494. required.</p>
  1495. <p>For older versions of Ant, you can use a custom
  1496. BuildListener that sends out an email
  1497. in the buildFinished() method. Will Glozer
  1498. &lt;will.glozer@jda.com&gt; has written such a listener based
  1499. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
  1500. The source is:</p>
  1501. <pre class="code">
  1502. import java.io.*;
  1503. import java.util.*;
  1504. import javax.mail.*;
  1505. import javax.mail.internet.*;
  1506. import org.apache.tools.ant.*;
  1507. /**
  1508. * A simple listener that waits for a build to finish and sends an email
  1509. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1510. * are fairly self explanatory.
  1511. *
  1512. * @author Will Glozer
  1513. * @version 1.05a 09/06/2000
  1514. */
  1515. public class BuildMonitor implements BuildListener {
  1516. protected Properties props;
  1517. /**
  1518. * Create a new BuildMonitor.
  1519. */
  1520. public BuildMonitor() throws Exception {
  1521. props = new Properties();
  1522. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1523. props.load(is);
  1524. is.close();
  1525. }
  1526. public void buildStarted(BuildEvent e) {
  1527. }
  1528. /**
  1529. * Determine the status of the build and the actions to follow, now that
  1530. * the build has completed.
  1531. *
  1532. * @param e Event describing the build status.
  1533. */
  1534. public void buildFinished(BuildEvent e) {
  1535. Throwable th = e.getException();
  1536. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1537. try {
  1538. String key = &quot;build.&quot; + status;
  1539. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1540. return;
  1541. }
  1542. Session session = Session.getDefaultInstance(props, null);
  1543. MimeMessage message = new MimeMessage(session);
  1544. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1545. props.getProperty(key + &quot;.email.to&quot;)));
  1546. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1547. BufferedReader br = new BufferedReader(new FileReader(
  1548. props.getProperty(&quot;build.log&quot;)));
  1549. StringWriter sw = new StringWriter();
  1550. String line = br.readLine();
  1551. while (line != null) {
  1552. sw.write(line);
  1553. sw.write(&quot;\n&quot;);
  1554. line = br.readLine();
  1555. }
  1556. br.close();
  1557. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1558. sw.close();
  1559. Transport transport = session.getTransport();
  1560. transport.connect();
  1561. transport.send(message);
  1562. transport.close();
  1563. } catch (Exception ex) {
  1564. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1565. ex.printStackTrace();
  1566. }
  1567. }
  1568. /**
  1569. * Parse a comma separated list of internet email addresses.
  1570. *
  1571. * @param s The list of addresses.
  1572. * @return Array of Addresses.
  1573. */
  1574. protected Address[] parseAddresses(String s) throws Exception {
  1575. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1576. Address[] addrs = new Address[st.countTokens()];
  1577. for (int i = 0; i &lt; addrs.length; i++) {
  1578. addrs[i] = new InternetAddress(st.nextToken());
  1579. }
  1580. return addrs;
  1581. }
  1582. public void messageLogged(BuildEvent e) {
  1583. }
  1584. public void targetStarted(BuildEvent e) {
  1585. }
  1586. public void targetFinished(BuildEvent e) {
  1587. }
  1588. public void taskStarted(BuildEvent e) {
  1589. }
  1590. public void taskFinished(BuildEvent e) {
  1591. }
  1592. }
  1593. </pre>
  1594. <p>With a <code>monitor.properties</code> like this:</p>
  1595. <pre class="code">
  1596. # configuration for build monitor
  1597. mail.transport.protocol=smtp
  1598. mail.smtp.host=&lt;host&gt;
  1599. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1600. build.log=build.log
  1601. build.failed.notify=true
  1602. build.failed.email.to=will.glozer@jda.com
  1603. build.failed.email.subject=Nightly build failed!
  1604. build.succeeded.notify=true
  1605. build.succeeded.email.to=will.glozer@jda.com
  1606. build.succeeded.email.subject=Nightly build succeeded!
  1607. </pre>
  1608. <p><code>monitor.properties</code> should be placed right next
  1609. to your compiled <code>BuildMonitor.class</code>. To use it,
  1610. invoke Ant like:</p>
  1611. <pre class="code">
  1612. ant -listener BuildMonitor -logfile build.log
  1613. </pre>
  1614. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1615. <code>activation.jar</code> from the
  1616. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1617. Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
  1618. <p class="faq">
  1619. <a name="listener-properties"></a>
  1620. How do I get at the properties that Ant was running
  1621. with from inside BuildListener?
  1622. </p>
  1623. <p>You can get at a hashtable with all the properties that Ant
  1624. has been using through the BuildEvent parameter. For
  1625. example:</p>
  1626. <pre class="code">
  1627. public void buildFinished(BuildEvent e) {
  1628. Hashtable table = e.getProject().getProperties();
  1629. String buildpath = (String)table.get(&quot;build.path&quot;);
  1630. ...
  1631. }
  1632. </pre>
  1633. <p>This is more accurate than just reading the same property
  1634. files that your project does, since it will give the correct
  1635. results for properties that were specified on the Ant command line.</p>
  1636. <p class="faq">
  1637. <a name="input-makes-exec-hang"></a>
  1638. <code>&lt;exec&gt;</code> causes other tasks to hang
  1639. or leads to strange behaviour of <code>&lt;input&gt;</code>
  1640. tasks.
  1641. </p>
  1642. <p>When Ant forks a new process for example by using the
  1643. <code>&lt;exec&gt;</code>, <code>&lt;apply&gt;</code>
  1644. or <code>&lt;java&gt;</code> tasks, it will also start a
  1645. new thread reading from standard input and sending
  1646. everything that it has read to that process.</p>
  1647. <p>Unfortunately Ant has no way to know whether the forked
  1648. process is ever going to read any input, so it will start such
  1649. a thread even if the process doesn't need one.</p>
  1650. <p>This behaviour leads to strange side effects like the Ant
  1651. process being suspended when a build forking new process is
  1652. run as a background process on Unix-like systems or
  1653. <code>&lt;input&gt;</code> tasks requiring additional inputs
  1654. if they come after an <code>&lt;exec&gt;</code> task.</p>
  1655. <p>Fortunately there is a workaround for this, always specify
  1656. <code>inputstring=""</code> for
  1657. any <code>&lt;exec&gt;</code> task (or one of its sibblings)
  1658. if you know the forked process doesn't consume any
  1659. input.</p>
  1660. <p class="faq">
  1661. <a name="170-requires-junit"></a>
  1662. Ant 1.7.0 doesn't build from sources without
  1663. JUnit
  1664. </p>
  1665. <p>When building Ant 1.7.0 from the source release without
  1666. junit.jar the build fails with the message "We cannot build
  1667. the test jar unless JUnit is present".</p>
  1668. <p>With Ant 1.7.0 we've started to add ant-testutil.jar as
  1669. part of the distribution and this causes a hard dependency on
  1670. JUnit - at least in version 1.7.0. Unfortunately the
  1671. installation docs don't say so.</p>
  1672. <p>There are two workarounds:</p>
  1673. <ol>
  1674. <li>Add junit.jar to your CLASSPATH when building Ant.</li>
  1675. <li>Change Ant's buildfile and remove test-jar from the
  1676. depends list of the dist-lite target.</li>
  1677. </ol>
  1678. <p class="faq">
  1679. <a name="remove-cr"></a>
  1680. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  1681. 1.3 on Unix
  1682. </p>
  1683. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1684. has DOS instead of Unix line endings; you must remove the
  1685. carriage-return characters from this file. This can be done by
  1686. using Ant's <code>&lt;fixcrlf&gt;</code> task
  1687. or something like:</p>
  1688. <pre class="code">
  1689. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1690. mv /tmp/foo $ANT_HOME/bin/antRun
  1691. </pre>
  1692. <p class="faq">
  1693. <a name="javadoc-cannot-execute"></a>
  1694. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1695. </p>
  1696. <p>There is a bug in the Solaris reference implementation of
  1697. 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>).
  1698. This also appears to be true under Linux. Moving the JDK to
  1699. the front of the PATH fixes the problem.</p>
  1700. <p class="faq">
  1701. <a name="delegating-classloader"></a>
  1702. &lt;style&gt; or &lt;junit&gt; ignores my
  1703. &lt;classpath&gt;
  1704. </p>
  1705. <p>Starting with Ant 1.7.0, &lt;junit&gt; will honor your
  1706. nested &lt;classpath&gt;.</p>
  1707. <p>These tasks don't ignore your classpath setting, you
  1708. are facing a common problem with delegating classloaders.</p>
  1709. <p>This question collects a common type of problem: A task
  1710. needs an external library and it has a nested classpath
  1711. element so that you can point it to this external library, but
  1712. that doesn't work unless you put the external library
  1713. into the <code>CLASSPATH</code> or place it in
  1714. <code>ANT_HOME/lib</code>.</p>
  1715. <p>Some background is necessary before we can discuss
  1716. solutions for <a href="#delegating-classloader-1.5">Ant
  1717. 1.5.x</a> and <a href="#delegating-classloader-1.6">Ant
  1718. 1.6.x</a>.</p>
  1719. <p>When you specify a nested <code>&lt;classpath&gt;</code> in
  1720. Ant, Ant creates a new class loader that uses the path you
  1721. have specified. It then tries to load additional classes from
  1722. this classloader.</p>
  1723. <p>In most cases - for example using &lt;style&gt; or
  1724. &lt;junit&gt; - Ant doesn't load the external library
  1725. directly, it is the loaded class that does so.</p>
  1726. <p>In the case of <code>&lt;junit&gt;</code> it is the task
  1727. implementation itself and in the case of
  1728. <code>&lt;style&gt;</code> it is the implementation of the
  1729. <code>org.apache.tools.ant.taskdefs.XSLTLiaison</code>
  1730. class.</p>
  1731. <p><em>As of Ant 1.7</em> <code>&lt;junit&gt;</code> no longer
  1732. requires you to have <code>junit.jar</code> in Ant's startup
  1733. classpath even if <code>ant-junit.jar</code> is present there.</p>
  1734. <p>Ant's class loader implementation uses Java's
  1735. 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>
  1736. the paragraph</p>
  1737. <blockquote>The <code>ClassLoader</code> class uses a
  1738. delegation model to search for classes and resources. Each
  1739. instance of <code>ClassLoader</code> has an associated parent
  1740. class loader. When called upon to find a class or resource, a
  1741. <code>ClassLoader</code> instance will delegate the search for
  1742. the class or resource to its parent class loader before
  1743. attempting to find the class or resource itself. The virtual
  1744. machine's built-in class loader, called the bootstrap
  1745. class loader, does not itself have a parent but may serve as
  1746. the parent of a <code>ClassLoader</code>
  1747. instance.</blockquote>
  1748. <p>The possible solutions depend on the version of Ant you
  1749. use, see the next sections.</p>
  1750. <p class="faq">
  1751. <a name="delegating-classloader-1.5"></a>
  1752. &lt;style&gt; or &lt;junit&gt; ignores my
  1753. &lt;classpath&gt; - Ant 1.5.x version
  1754. </p>
  1755. <p>Please read <a href="#delegating-classloader">the previous
  1756. entry</a> before you go ahead.</p>
  1757. <p>First of all let's state that Ant's wrapper script
  1758. (<code>ant</code> or <code>ant.bat</code>) adds all
  1759. <code>.jar</code> files from <code>ANT_HOME/lib</code> to
  1760. <code>CLASSPATH</code>, therefore "in
  1761. <code>CLASSPATH</code>" shall mean "either in your
  1762. <code>CLASSPATH</code> environment variable or
  1763. <code>ANT_HOME/lib</code>" for the rest of this
  1764. answer.</p>
  1765. <p>The root of the problem is that the class that needs the
  1766. external library is on the <code>CLASSPATH</code>.</p>
  1767. <p>Let's see what happens when you load the &lt;junit&gt;
  1768. task. Ant's class loader will consult the
  1769. bootstrap class loader first, which tries to load classes from
  1770. <code>CLASSPATH</code>. The bootstrap class loader
  1771. doesn't know anything about Ant's class loader or
  1772. even the path you have specified.</p>
  1773. <p>If the bootstrap class loader can load the class Ant has
  1774. asked it to load (which it can if <code>optional.jar</code> is
  1775. part of <code>CLASSPATH</code>), this class will try to load
  1776. the external library from <code>CLASSPATH</code> as well - it
  1777. doesn't know anything else - and will not find it unless
  1778. the library is in <code>CLASSPATH</code> as well.</p>
  1779. <p>To solve this, you have two major options:</p>
  1780. <ol>
  1781. <li>put all external libraries you need in
  1782. <code>CLASSPATH</code> as well this is not what you want,
  1783. otherwise you wouldn't have found this FAQ entry.</li>
  1784. <li>remove the class that loads the external library from
  1785. the <code>CLASSPATH</code>.</li>
  1786. </ol>
  1787. <p>The easiest way to do this is to remove
  1788. <code>optional.jar</code> from <code>ANT_HOME/lib</code>. If
  1789. you do so, you will have to <code>&lt;taskdef&gt;</code> all
  1790. optional tasks and use nested <code>&lt;classpath&gt;</code>
  1791. elements in the <code>&lt;taskdef&gt;</code> tasks that point
  1792. to the new location of <code>optional.jar</code>. Also,
  1793. don't forget to add the new location of
  1794. <code>optional.jar</code> to the
  1795. <code>&lt;classpath&gt;</code> of your
  1796. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code>
  1797. task.</p>
  1798. <p>If you want to avoid to <code>&lt;taskdef&gt;</code> all
  1799. optional tasks you need, the only other option is to remove
  1800. the classes that should not be loaded via the bootstrap class
  1801. loader from <code>optional.jar</code> and put them into a
  1802. separate archive. Add this separate archive to the
  1803. <code>&lt;classpath&gt;</code> of your
  1804. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code> task
  1805. - and make sure the separate archive is not in
  1806. <code>CLASSPATH</code>.</p>
  1807. <p>In the case of <code>&lt;junit&gt;</code> you'd have
  1808. to remove all classes that are in the
  1809. <code>org/apache/tools/ant/taskdefs/optional/junit</code>
  1810. directory, in the <code>&lt;style&gt;</code> case it is one of
  1811. the <code>*Liaison</code> classes in
  1812. <code>org/apache/tools/ant/taskdefs/optional</code>.</p>
  1813. <p>If you use the option to break up <code>optional.jar</code>
  1814. for <code>&lt;junit&gt;</code> or remove
  1815. <code>ant-junit.jar</code>, you still have to use a
  1816. <code>&lt;taskdef&gt;</code> with a nested
  1817. <code>&lt;classpath&gt;</code> to define the junit task.</p>
  1818. <p class="faq">
  1819. <a name="delegating-classloader-1.6"></a>
  1820. &lt;style&gt; or &lt;junit&gt; ignores my
  1821. &lt;classpath&gt; - Ant 1.6.x version
  1822. </p>
  1823. <p>Please read <a href="#delegating-classloader">the general
  1824. entry</a> before you go ahead.</p>
  1825. <p>The wrapper script of Ant 1.6.x no longer adds the contents
  1826. of <code>ANT_HOME/lib</code> to <code>CLASSPATH</code>,
  1827. instead Ant will create a classloader on top of the bootstrap
  1828. classloader - let's call it the coreloader for the rest of
  1829. this answer - which holds the contents of
  1830. <code>ANT_HOME/lib</code>. Ant's core and its tasks will be
  1831. loaded through this classloader and not the bootstrap
  1832. classloader.</p>
  1833. <p>This causes some small but notable differences between Ant
  1834. 1.5.x and 1.6.x. Most importantly, a third-party task that is
  1835. part of <code>CLASSPATH</code> will no longer work in Ant
  1836. 1.6.x since the task now can't find Ant's classes. In a sense
  1837. this is the same problem this entry is about, only
  1838. <code>ant.jar</code> has become the external library in
  1839. question now.</p>
  1840. <p>This coreloader also holds the contents of
  1841. <code>~/.ant/lib</code> and any file or directory that has
  1842. been specified using Ant's <code>-lib</code> command line
  1843. argument.</p>
  1844. <p>Let's see what happens when you load the &lt;junit&gt;
  1845. task. Ant's class loader will consult the bootstrap
  1846. class loader first, which tries to load classes from
  1847. <code>CLASSPATH</code>. The bootstrap class loader
  1848. doesn't know anything about Ant's class loader or
  1849. even the path you have specified. If it fails to find the
  1850. class using the bootstrap classloader it will try the
  1851. coreloader next. Again, the coreloader doesn't know anything
  1852. about your path.</p>
  1853. <p>If the coreloader can load the class Ant has asked it to
  1854. load (which it can if <code>ant-junit.jar</code> is in
  1855. <code>ANT_HOME/lib</code>), this class will try to load the
  1856. external library from coreloader as well - it doesn't
  1857. know anything else - and will not find it unless the library
  1858. is in <code>CLASSPATH</code> or the coreloader as well.</p>
  1859. <p>To solve this, you have the following major options:</p>
  1860. <ol>
  1861. <li>put all external libraries you need in
  1862. <code>CLASSPATH</code> as well this is not what you want,
  1863. otherwise you wouldn't have found this FAQ entry.</li>
  1864. <li>put all external libraries you need in
  1865. <code>ANT_HOME/lib</code> or <code>.ant/lib</code>. This
  1866. probably still isn't what you want, but you might reconsider
  1867. the <code>.ant/lib</code> option.</li>
  1868. <li>Always start Ant with the <code>-lib</code> command line
  1869. switch and point to your external libraries (or the
  1870. directories holding them).</li>
  1871. <li>remove the class that loads the external library from
  1872. the coreloader.</li>
  1873. </ol>
  1874. <p>In Ant 1.6 <code>optional.jar</code> has been split into
  1875. multiple jars, each one containing classes with the same
  1876. dependencies on external libraries. You can move the
  1877. "offending" jar out of <code>ANT_HOME/lib</code>. For the
  1878. <code>&lt;junit&gt;</code> task it would be
  1879. <code>ant-junit.jar</code> and for <code>&lt;style&gt;</code>
  1880. it would be <code>ant-trax.jar</code>
  1881. or <code>ant-xslp.jar</code> -
  1882. depending on the processor you use.</p>
  1883. <p>If you do so, you will have to <code>&lt;taskdef&gt;</code>
  1884. all optional tasks that need the external library and use
  1885. nested <code>&lt;classpath&gt;</code> elements in the
  1886. <code>&lt;taskdef&gt;</code> tasks that point to the new
  1887. location of <code>ant-*.jar</code>. Also, don't forget
  1888. to add the new location of <code>ant-*.jar</code> to the
  1889. <code>&lt;classpath&gt;</code> of your
  1890. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code>
  1891. task.</p>
  1892. <p>For example</p>
  1893. <pre class="code">
  1894. &lt;taskdef name=&quot;junit&quot;
  1895. class=&quot;org.apache.tools.ant.taskdefs.optional.junit.JUnitTask&quot;&gt;
  1896. &lt;classpath&gt;
  1897. &lt;pathelement location=&quot;HOME-OF/junit.jar&quot;/&gt;
  1898. &lt;pathelement location=&quot;NEW-HOME-OF/ant-junit.jar&quot;/&gt;
  1899. &lt;/classpath&gt;
  1900. &lt;/taskdef&gt;
  1901. </pre>
  1902. <p class="faq">
  1903. <a name="winxp-jdk14-ant14"></a>
  1904. When running Ant 1.4 on Windows XP and JDK 1.4, I get
  1905. various errors when trying to <code>&lt;exec&gt;</code>, fork
  1906. <code>&lt;java&gt;</code> or access environment
  1907. variables.
  1908. </p>
  1909. <p>Ant &lt; 1.5 doesn't recognize Windows XP as a flavor
  1910. of Windows that runs <code>CMD.EXE</code> instead of
  1911. <code>COMMAND.COM</code>. JDK 1.3 will tell Ant that Windows
  1912. XP is Windows 2000 so the problem doesn't show up
  1913. there.</p>
  1914. <p>Apart from upgrading to Ant 1.5 or better, setting the
  1915. environment variable <code>ANT_OPTS</code> to
  1916. <code>-Dos.name=Windows_NT</code> prior to invoking Ant has
  1917. been confirmed as a workaround.</p>
  1918. <p class="faq">
  1919. <a name="1.5-cygwin-sh"></a>
  1920. The <code>ant</code> wrapper script of Ant 1.5 fails
  1921. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  1922. path.
  1923. </p>
  1924. <p>This problem has been reported only hours after Ant 1.5 has
  1925. been released, see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=10664">Bug
  1926. 10664</a> and all its duplicates.</p>
  1927. <p>A fixed version of the wrapper script can be found <a href="http://ant.apache.org/old-releases/v1.5/errata/">here</a>.
  1928. Simply replace your script with this version.</p>
  1929. <p class="faq">
  1930. <a name="1.5.2-zip-broken"></a>
  1931. <code>&lt;zip&gt;</code> is broken in Ant 1.5.2.
  1932. </p>
  1933. <p>Yes, it is.</p>
  1934. <p>The problem reported by most people - see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17648">Bug
  1935. 17648</a> and all its duplicates - is that Ant creates
  1936. archives that a partially unreadable by WinZIP. Luckily
  1937. <code>jar</code> deals with the archives and so the generated
  1938. jars/wars/ears will most likely work for you anyway.</p>
  1939. <p>There are additional problems, see bugs <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17780">Bug
  1940. 17780</a>, <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=17871">Bug
  1941. 17871</a> and <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=18403">Bug
  1942. 18403</a>. All of them are supposed to be fixed with Ant
  1943. 1.5.3 (and only 18403 should exist in 1.5.3beta1).</p>
  1944. <p class="faq">
  1945. <a name="unknownelement.taskcontainer"></a>
  1946. Why do my custom task containers see Unknown Elements in Ant 1.6
  1947. - they worked in Ant 1.5?
  1948. </p>
  1949. <p>
  1950. The objects added in TaskContainer.addTask(Task task)
  1951. have changed from Tasks to UnknownElements.
  1952. </p>
  1953. <p>
  1954. There was a number of valid reasons for this change. But the backward
  1955. compatibility problems were not noticed until after Ant 1.6.0 was
  1956. released.
  1957. </p>
  1958. <p>
  1959. Your container class will need to be modified to check if the Task
  1960. is an UnknownElement and call perform on it to
  1961. convert it to a Task and to execute it.
  1962. (see apache.tools.ant.taskdefs.Sequential)
  1963. </p>
  1964. <p>
  1965. If you want to do more processing on the task,
  1966. you need to use the techniques in apache.tools.ant.taskdefs.Antlib#execute()
  1967. This does make use of one 1.6 method call (UE#getRealObject()),
  1968. you need to use UE#getTask() instead - this will
  1969. return null for non tasks (types like fileset id=x).
  1970. </p>
  1971. <p>
  1972. So.. iterate over the tasks, if they are UEs, convert them to
  1973. tasks, using UE#maybeConfigure and UE#getTask()
  1974. </p>
  1975. <pre class="code">
  1976. for (Iterator i = tasks.iterator(); i.hasNext();) {
  1977. Task t = (Task) i.next();
  1978. if (t instanceof UnknownElement) {
  1979. ((UnknownElement) t).maybeConfigure();
  1980. t = ((UnknownElement) t).getTask();
  1981. if (t == null) {
  1982. continue;
  1983. }
  1984. }
  1985. // .... original Custom code
  1986. }
  1987. </pre>
  1988. <p>
  1989. This approach should work for ant1.5 and ant1.6.
  1990. </p>
  1991. <p class="faq">
  1992. <a name="java.exception.stacktrace"></a>
  1993. The program I run via &lt;java&gt; throws an exception but I
  1994. can't seem to get the full stack trace.
  1995. </p>
  1996. <p>This is a know bug that has been fixed after the release of
  1997. Ant 1.6.1.</p>
  1998. <p>As a workaround, run your &lt;java&gt; task with
  1999. <code>fork="true"</code> and Ant will display the full
  2000. trace.</p>
  2001. <p class="faq">
  2002. <a name="junit-no-runtime-xml"></a>
  2003. Using format="xml", &lt;junit&gt; fails with a
  2004. <code>NoClassDefFoundError</code> if forked.
  2005. </p>
  2006. <p>The XML formatter needs the <a href="http://www.w3.org/DOM/">DOM classes</a> to work. If you
  2007. are using JDK 1.4 or later they are included with your Java
  2008. Runtime and this problem won't occur. If you are running JDK
  2009. 1.3 or earlier, the DOM classes have to be on your
  2010. &lt;junit&gt; task's &lt;classpath&gt;.</p>
  2011. <p>Prior to Ant 1.6.0 Ant would include the DOM classes from
  2012. the XML parser that is used by Ant itself if you set the
  2013. includeAntRuntime attribute to true (the default). With Ant
  2014. 1.6.0 this has been changed as this behavior made it
  2015. impossible to use a different XML parser in your tests.</p>
  2016. <p>This means that you have to take care of the DOM classes
  2017. explicitly starting with Ant 1.6.0. If you don't need to set
  2018. up a different XML parser for your tests, the easiest solution
  2019. is to add</p>
  2020. <pre class="code">
  2021. &lt;pathelement path=&quot;${ant.home}/lib/xml-apis.jar:${ant.home}/lib/xercesImpl.jar&quot;/&gt;
  2022. </pre>
  2023. <p>to your task's &lt;classpath&gt;.</p>
  2024. <p class="faq">
  2025. <a name="xalan-jdk1.5"></a>
  2026. <code>&lt;junitreport&gt;</code> doesn't work with JDK 1.5 but
  2027. worked fine with JDK 1.4.
  2028. </p>
  2029. <p>While JDK 1.4.x contains a version of Xalan-J 2, JDK 1.5
  2030. (and later?) have <a href="http://java.sun.com/j2se/1.5.0/compatibility.html#4959783">moved
  2031. to XSLTC</a>. Since this task uses Xalan's redirect
  2032. extensions for its internal stylesheet, Ant prior to 1.6.2 didn't support
  2033. XSLTC. This means that you have to install <a href="http://xml.apache.org/xalan-j/">Xalan-J 2</a> in order
  2034. to use this task with JDK 1.5 in older versions of Ant.</p>
  2035. <p>Starting with Ant 1.6.2 <code>&lt;junitreport&gt;</code>
  2036. supports JDK 1.5.</p>
  2037. </div>
  2038. </div>
  2039. <p class="copyright">
  2040. <script type="text/javascript" language="JavaScript"><!--
  2041. document.write(" - "+"Last Published: " + document.lastModified);
  2042. // -->
  2043. </script>
  2044. </p>
  2045. </body>
  2046. </html>