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

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