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 91 KiB

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