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

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