You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

faq.html 95 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089
  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. <p>With Ant &gt;= 1.5, you can also use nested
  766. <code>&lt;compilerarg&gt;</code> elements with the
  767. <code>&lt;javac&gt;</code> task.</p>
  768. </blockquote>
  769. </td></tr>
  770. </table>
  771. </a>
  772. <a name="shell-redirect-1">
  773. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  774. <tr><td bgcolor="#828DA6">
  775. <font color="#ffffff" face="arial,helvetica,sanserif">
  776. <strong>
  777. How do I include a &lt; character in my command-line arguments?
  778. </strong>
  779. </font>
  780. </td></tr>
  781. <tr><td>
  782. <blockquote>
  783. <p>The short answer is "Use: <code>&amp;lt;</code>".</p>
  784. <p>The long answer is that this probably won't do what you
  785. want anyway (see <a href="#shell-redirect-2">the next
  786. section</a>).</p>
  787. </blockquote>
  788. </td></tr>
  789. </table>
  790. </a>
  791. <a name="shell-redirect-2">
  792. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  793. <tr><td bgcolor="#828DA6">
  794. <font color="#ffffff" face="arial,helvetica,sanserif">
  795. <strong>
  796. How do I redirect standard input or standard output
  797. in the <code>&lt;exec&gt;</code> task?
  798. </strong>
  799. </font>
  800. </td></tr>
  801. <tr><td>
  802. <blockquote>
  803. <p>Say you want to redirect the standard input stream of the
  804. <code>cat</code> command to read from a file, something
  805. like:</p>
  806. <div align="left">
  807. <table cellspacing="4" cellpadding="0" border="0">
  808. <tr>
  809. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  810. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  811. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  812. </tr>
  813. <tr>
  814. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  815. <td bgcolor="#ffffff"><pre>
  816. shell-prompt&gt; cat &lt; foo
  817. </pre></td>
  818. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  819. </tr>
  820. <tr>
  821. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  822. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  823. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  824. </tr>
  825. </table>
  826. </div>
  827. <p>and try to translate it into</p>
  828. <div align="left">
  829. <table cellspacing="4" cellpadding="0" border="0">
  830. <tr>
  831. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  832. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  833. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  834. </tr>
  835. <tr>
  836. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  837. <td bgcolor="#ffffff"><pre>
  838. &lt;exec executable=&quot;cat&quot;&gt;
  839. &lt;arg value=&quot;&amp;lt;&quot; /&gt;
  840. &lt;arg value=&quot;foo&quot; /&gt;
  841. &lt;/exec&gt;
  842. </pre></td>
  843. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  844. </tr>
  845. <tr>
  846. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  847. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  848. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  849. </tr>
  850. </table>
  851. </div>
  852. <p>This will not do what you expect. The input redirection is
  853. performed by your shell, not the command itself, so this
  854. should read:</p>
  855. <div align="left">
  856. <table cellspacing="4" cellpadding="0" border="0">
  857. <tr>
  858. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  859. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  860. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  861. </tr>
  862. <tr>
  863. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  864. <td bgcolor="#ffffff"><pre>
  865. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  866. &lt;arg value=&quot;-c&quot; /&gt;
  867. &lt;arg value=&quot;cat &amp;lt; foo&quot; /&gt;
  868. &lt;/exec&gt;
  869. </pre></td>
  870. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  871. </tr>
  872. <tr>
  873. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  874. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  875. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  876. </tr>
  877. </table>
  878. </div>
  879. <p>Note that you must use the <code>value</code> attribute of
  880. <code>&lt;arg&gt;</code> in the last element, in order to have
  881. the command passed as a single, quoted argument. Alternatively,
  882. you can use:</p>
  883. <div align="left">
  884. <table cellspacing="4" cellpadding="0" border="0">
  885. <tr>
  886. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  887. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  888. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  889. </tr>
  890. <tr>
  891. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  892. <td bgcolor="#ffffff"><pre>
  893. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  894. &lt;arg line='-c &quot;cat &amp;lt; foo&quot;'/&gt;
  895. &lt;/exec&gt;
  896. </pre></td>
  897. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  898. </tr>
  899. <tr>
  900. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  901. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  902. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  903. </tr>
  904. </table>
  905. </div>
  906. <p>Note the double-quotes nested inside the single-quotes.</p>
  907. </blockquote>
  908. </td></tr>
  909. </table>
  910. </a>
  911. <a name="batch-shell-execute">
  912. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  913. <tr><td bgcolor="#828DA6">
  914. <font color="#ffffff" face="arial,helvetica,sanserif">
  915. <strong>
  916. How do I execute a batch file or shell script from Ant?
  917. </strong>
  918. </font>
  919. </td></tr>
  920. <tr><td>
  921. <blockquote>
  922. <p>On native Unix systems, you should be able to run shell scripts
  923. directly. On systems running a Unix-type shell (for example, Cygwin
  924. on Windows) execute the (command) shell instead - <code>cmd</code>
  925. for batch files, <code>sh</code> for shell scripts - then pass the
  926. batch file or shell script (plus any arguments to the script)
  927. as a single command, using the <code>/c</code> or
  928. <code>-c</code> switch, respectively. See
  929. <a href="#shell-redirect-2">the above section</a>
  930. for example <code>&lt;exec&gt;</code> tasks
  931. executing <code>sh</code>. For batch files, use something like:</p>
  932. <div align="left">
  933. <table cellspacing="4" cellpadding="0" border="0">
  934. <tr>
  935. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  936. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  937. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  938. </tr>
  939. <tr>
  940. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  941. <td bgcolor="#ffffff"><pre>
  942. &lt;exec dir=&quot;.&quot; executable=&quot;cmd&quot; os=&quot;Windows NT&quot;&gt;
  943. &lt;arg line=&quot;/c test.bat&quot;/&gt;
  944. &lt;/exec&gt;
  945. </pre></td>
  946. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  947. </tr>
  948. <tr>
  949. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  950. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  951. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  952. </tr>
  953. </table>
  954. </div>
  955. </blockquote>
  956. </td></tr>
  957. </table>
  958. </a>
  959. <a name="defaultexcludes">
  960. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  961. <tr><td bgcolor="#828DA6">
  962. <font color="#ffffff" face="arial,helvetica,sanserif">
  963. <strong>
  964. I've used a <code>&lt;delete&gt;</code> task to delete
  965. unwanted
  966. SourceSafe control files (CVS files, editor backup files, etc.), but
  967. it doesn't seem to work; the files never get deleted. What's
  968. wrong?
  969. </strong>
  970. </font>
  971. </td></tr>
  972. <tr><td>
  973. <blockquote>
  974. <p>This is probably happening because, by default, Ant excludes
  975. SourceSafe control files (<code>vssver.scc</code>) and certain other
  976. files from FileSets.</p>
  977. <p>Here's what you probably did:</p>
  978. <div align="left">
  979. <table cellspacing="4" cellpadding="0" border="0">
  980. <tr>
  981. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  982. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  983. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  984. </tr>
  985. <tr>
  986. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  987. <td bgcolor="#ffffff"><pre>
  988. &lt;delete&gt;
  989. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  990. &lt;/delete&gt;
  991. </pre></td>
  992. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  993. </tr>
  994. <tr>
  995. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  996. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  997. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  998. </tr>
  999. </table>
  1000. </div>
  1001. <p>You need to switch off the default exclusions,
  1002. and it will work:</p>
  1003. <div align="left">
  1004. <table cellspacing="4" cellpadding="0" border="0">
  1005. <tr>
  1006. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1007. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1008. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1009. </tr>
  1010. <tr>
  1011. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1012. <td bgcolor="#ffffff"><pre>
  1013. &lt;delete&gt;
  1014. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  1015. defaultexcludes=&quot;no&quot;/&gt;
  1016. &lt;/delete&gt;
  1017. </pre></td>
  1018. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1019. </tr>
  1020. <tr>
  1021. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1022. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1023. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1024. </tr>
  1025. </table>
  1026. </div>
  1027. <p>For a complete listing of the patterns that are excluded
  1028. by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
  1029. manual</a>.</p>
  1030. </blockquote>
  1031. </td></tr>
  1032. </table>
  1033. </a>
  1034. <a name="multi-conditions">
  1035. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1036. <tr><td bgcolor="#828DA6">
  1037. <font color="#ffffff" face="arial,helvetica,sanserif">
  1038. <strong>
  1039. I want to execute a particular target only if
  1040. multiple conditions are true.
  1041. </strong>
  1042. </font>
  1043. </td></tr>
  1044. <tr><td>
  1045. <blockquote>
  1046. <p>There are actually several answers to this question.</p>
  1047. <p>If you have only one set and one unset property to test,
  1048. you can specify both an <code>if</code> and an <code>unless</code>
  1049. attribute for the target, and they will act as if they
  1050. are "anded" together.</p>
  1051. <p>If you are using a version of Ant 1.3 or earlier, the
  1052. way to work with all other cases is to chain targets together
  1053. to determine the specific state you want to test for.</p>
  1054. <p>To see how this works, assume you have three properties:
  1055. <code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
  1056. You want to test that <code>prop1</code> and <code>prop2</code>
  1057. are set, and that <code>prop3</code> is not. If the condition
  1058. holds true you want to echo "yes".</p>
  1059. <p>Here is the implementation in Ant 1.3 and earlier:</p>
  1060. <div align="left">
  1061. <table cellspacing="4" cellpadding="0" border="0">
  1062. <tr>
  1063. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1064. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1065. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1066. </tr>
  1067. <tr>
  1068. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1069. <td bgcolor="#ffffff"><pre>
  1070. &lt;target name=&quot;cond&quot; depends=&quot;cond-if&quot;/&gt;
  1071. &lt;target name=&quot;cond-if&quot; if=&quot;prop1&quot;&gt;
  1072. &lt;antcall target=&quot;cond-if-2&quot;/&gt;
  1073. &lt;/target&gt;
  1074. &lt;target name=&quot;cond-if-2&quot; if=&quot;prop2&quot;&gt;
  1075. &lt;antcall target=&quot;cond-if-3&quot;/&gt;
  1076. &lt;/target&gt;
  1077. &lt;target name=&quot;cond-if-3&quot; unless=&quot;prop3&quot;&gt;
  1078. &lt;echo message=&quot;yes&quot;/&gt;
  1079. &lt;/target&gt;
  1080. </pre></td>
  1081. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1082. </tr>
  1083. <tr>
  1084. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1085. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1086. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1087. </tr>
  1088. </table>
  1089. </div>
  1090. <p>Note: <code>&lt;antcall&gt;</code> tasks do <em>not</em> pass
  1091. property changes back up to the environment they were called
  1092. from, so you would'nt be able to, for example, set a
  1093. <code>result</code> property in the <code>cond-if-3</code> target,
  1094. then do
  1095. <code>&lt;echo message="result is ${result}"/&gt;</code>
  1096. in the <code>cond</code> target.</p>
  1097. <p>Starting with Ant 1.4, you can use the
  1098. <code>&lt;condition&gt;</code> task.</p>
  1099. <div align="left">
  1100. <table cellspacing="4" cellpadding="0" border="0">
  1101. <tr>
  1102. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1103. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1104. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1105. </tr>
  1106. <tr>
  1107. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1108. <td bgcolor="#ffffff"><pre>
  1109. &lt;target name=&quot;cond&quot; depends=&quot;cond-if,cond-else&quot;/&gt;
  1110. &lt;target name=&quot;check-cond&quot;&gt;
  1111. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1112. &lt;and&gt;
  1113. &lt;not&gt;
  1114. &lt;equals arg1=&quot;${prop1}&quot; arg2=&quot;$${prop1}&quot; /&gt;
  1115. &lt;/not&gt;
  1116. &lt;not&gt;
  1117. &lt;equals arg1=&quot;${prop2}&quot; arg2=&quot;$${prop2}&quot; /&gt;
  1118. &lt;/not&gt;
  1119. &lt;equals arg1=&quot;${prop3}&quot; arg2=&quot;$${prop3}&quot; /&gt;
  1120. &lt;/and&gt;
  1121. &lt;/condition&gt;
  1122. &lt;/target&gt;
  1123. &lt;target name=&quot;cond-if&quot; depends=&quot;check-cond&quot; if=&quot;cond-is-true&quot;&gt;
  1124. &lt;echo message=&quot;yes&quot;/&gt;
  1125. &lt;/target&gt;
  1126. &lt;target name=&quot;cond-else&quot; depends=&quot;check-cond&quot; unless=&quot;cond-is-true&quot;&gt;
  1127. &lt;echo message=&quot;no&quot;/&gt;
  1128. &lt;/target&gt;
  1129. </pre></td>
  1130. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1131. </tr>
  1132. <tr>
  1133. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1134. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1135. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1136. </tr>
  1137. </table>
  1138. </div>
  1139. <p>This version takes advantage of two things:</p>
  1140. <ul>
  1141. <li>If a property <code>a</code> has not been set,
  1142. <code>${a}</code> will evaluate to <code>${a}</code>.</li>
  1143. <li>To get a literal <code>$</code> in Ant, you have to
  1144. escape it with another <code>$</code> - this will also break
  1145. the special treatment of the <code>${</code> sequence.</li>
  1146. </ul>
  1147. <p>Because testing for a literal <code>${property}</code> string
  1148. isn't all that readable or easy to understand,
  1149. post-1.4.1 Ant introduces the <code>&lt;isset&gt;</code> element
  1150. to the <code>&lt;condition&gt;</code> task.</p>
  1151. <p>Here is the previous example done using
  1152. <code>&lt;isset&gt;</code>:</p>
  1153. <div align="left">
  1154. <table cellspacing="4" cellpadding="0" border="0">
  1155. <tr>
  1156. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1157. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1158. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1159. </tr>
  1160. <tr>
  1161. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1162. <td bgcolor="#ffffff"><pre>
  1163. &lt;target name=&quot;check-cond&quot;&gt;
  1164. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1165. &lt;and&gt;
  1166. &lt;isset property=&quot;prop1&quot;/&gt;
  1167. &lt;isset property=&quot;prop2&quot;/&gt;
  1168. &lt;not&gt;
  1169. &lt;isset property=&quot;prop3&quot;/&gt;
  1170. &lt;/not&gt;
  1171. &lt;/and&gt;
  1172. &lt;/condition&gt;
  1173. &lt;/target&gt;
  1174. </pre></td>
  1175. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1176. </tr>
  1177. <tr>
  1178. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1179. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1180. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1181. </tr>
  1182. </table>
  1183. </div>
  1184. <p>The last option is to use a scripting language to set the
  1185. properties. This can be particularly handy when you need much
  1186. finer control than the simple conditions shown here but, of
  1187. course, comes with the overhead of adding JAR files to support
  1188. the language, to say nothing of the added maintenance in requiring
  1189. two languages to implement a single system. See the
  1190. <a href="manual/OptionalTasks/script.html">
  1191. <code>&lt;script&gt;</code> task documentation</a> for more
  1192. details.</p>
  1193. </blockquote>
  1194. </td></tr>
  1195. </table>
  1196. </a>
  1197. <a name="stop-dependency">
  1198. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1199. <tr><td bgcolor="#828DA6">
  1200. <font color="#ffffff" face="arial,helvetica,sanserif">
  1201. <strong>
  1202. I have a target I want to skip if a property is set,
  1203. so I have <code>unless="property"</code> as an attribute
  1204. of the target, but all the targets this target
  1205. depends on are still executed. Why?
  1206. </strong>
  1207. </font>
  1208. </td></tr>
  1209. <tr><td>
  1210. <blockquote>
  1211. <p>The list of dependencies is generated by Ant before any of the
  1212. targets are run. This allows dependent targets, such as an
  1213. <code>init</code> target, to set properties that can control the
  1214. execution of the targets higher in the dependency graph. This
  1215. is a good thing.</p>
  1216. <p>However, when your dependencies break down the
  1217. higher-level task
  1218. into several smaller steps, this behaviour becomes
  1219. counter-intuitive. There are a couple of solutions available:
  1220. </p>
  1221. <ol>
  1222. <li>Put the same condition on each of the dependent targets.</li>
  1223. <li>Execute the steps using <code>&lt;antcall&gt;</code>,
  1224. instead of specifying them inside the <code>depends</code>
  1225. attribute.</li>
  1226. </ol>
  1227. </blockquote>
  1228. </td></tr>
  1229. </table>
  1230. </a>
  1231. <a name="include-order">
  1232. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1233. <tr><td bgcolor="#828DA6">
  1234. <font color="#ffffff" face="arial,helvetica,sanserif">
  1235. <strong>
  1236. In my <code>&lt;fileset&gt;</code>, I've put in an
  1237. <code>&lt;exclude&gt;</code> of all files followed by an
  1238. <code>&lt;include&gt;</code> of just the files I want, but it
  1239. isn't giving me any files at all. What's wrong?
  1240. </strong>
  1241. </font>
  1242. </td></tr>
  1243. <tr><td>
  1244. <blockquote>
  1245. <p>The order of the <code>&lt;include&gt;</code> and
  1246. <code>&lt;exclude&gt;</code> tags within a <code>&lt;fileset&gt;</code>
  1247. is ignored when the FileSet is created. Instead, all of the
  1248. <code>&lt;include&gt;</code> elements are processed together,
  1249. followed by all of the <code>&lt;exclude&gt;</code>
  1250. elements. This means that the <code>&lt;exclude&gt;</code>
  1251. elements only apply to the file list produced by the
  1252. <code>&lt;include&gt;</code> elements.</p>
  1253. <p>To get the files you want, focus on just the
  1254. <code>&lt;include&gt;</code> patterns that would be necessary
  1255. to get them. If you find you need to trim the list that the
  1256. <code>&lt;include&gt;</code> elements
  1257. produce, then use <code>&lt;exclude&gt;</code> elements.</p>
  1258. </blockquote>
  1259. </td></tr>
  1260. </table>
  1261. </a>
  1262. <a name="encoding">
  1263. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1264. <tr><td bgcolor="#828DA6">
  1265. <font color="#ffffff" face="arial,helvetica,sanserif">
  1266. <strong>
  1267. How can I include national characters like German
  1268. umlauts in my build file?
  1269. </strong>
  1270. </font>
  1271. </td></tr>
  1272. <tr><td>
  1273. <blockquote>
  1274. <p>You need to tell the XML parser which character encoding
  1275. your build file uses, this is done inside the <a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd">XML
  1276. declaration</a>.</p>
  1277. <p>By default the parser assumes you are using the UTF-8
  1278. encoding instead of your platform's default. For most Western
  1279. European countries you should set the encoding to
  1280. <code>ISO-8859-1</code>. To do so, make the very first line
  1281. of you build file read like</p>
  1282. <div align="left">
  1283. <table cellspacing="4" cellpadding="0" border="0">
  1284. <tr>
  1285. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1286. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1287. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1288. </tr>
  1289. <tr>
  1290. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1291. <td bgcolor="#ffffff"><pre>
  1292. &lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
  1293. </pre></td>
  1294. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1295. </tr>
  1296. <tr>
  1297. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1298. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1299. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1300. </tr>
  1301. </table>
  1302. </div>
  1303. </blockquote>
  1304. </td></tr>
  1305. </table>
  1306. </a>
  1307. <a name="integration">
  1308. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1309. <tr><td bgcolor="#828DA6">
  1310. <font color="#ffffff" face="arial,helvetica,sanserif">
  1311. <strong>
  1312. Is Ant supported by my IDE/Editor?
  1313. </strong>
  1314. </font>
  1315. </td></tr>
  1316. <tr><td>
  1317. <blockquote>
  1318. <p>See the <a href="external.html#IDE and Editor Integration">section
  1319. on IDE integration</a> on our External Tools and Tasks page.</p>
  1320. </blockquote>
  1321. </td></tr>
  1322. </table>
  1323. </a>
  1324. <a name="emacs-mode">
  1325. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1326. <tr><td bgcolor="#828DA6">
  1327. <font color="#ffffff" face="arial,helvetica,sanserif">
  1328. <strong>
  1329. Why doesn't (X)Emacs/vi/MacOS X's project builder
  1330. correctly parse the error messages generated by Ant?
  1331. </strong>
  1332. </font>
  1333. </td></tr>
  1334. <tr><td>
  1335. <blockquote>
  1336. <p>Ant adds a "banner" with the name of the current
  1337. task in front of all logging messages - and there are no built-in
  1338. regular expressions in your editor that would account for
  1339. this.</p>
  1340. <p>You can disable this banner by invoking Ant with the
  1341. <code>-emacs</code> switch. To make Ant autodetect
  1342. Emacs' compile mode, put this into your
  1343. <code>.antrc</code> (contributed by Ville Skytt).</p>
  1344. <div align="left">
  1345. <table cellspacing="4" cellpadding="0" border="0">
  1346. <tr>
  1347. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1348. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1349. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1350. </tr>
  1351. <tr>
  1352. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1353. <td bgcolor="#ffffff"><pre>
  1354. # Detect (X)Emacs compile mode
  1355. if [ &quot;$EMACS&quot; = &quot;t&quot; ] ; then
  1356. ANT_ARGS=&quot;$ANT_ARGS -emacs&quot;
  1357. ANT_OPTS=&quot;$ANT_OPTS -Dbuild.compiler.emacs=true&quot;
  1358. fi
  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>Alternatively, you can add the following snippet to your
  1370. <code>.emacs</code> to make Emacs understand Ant's
  1371. output.</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. (require 'compile)
  1383. (setq compilation-error-regexp-alist
  1384. (append (list
  1385. ;; works for jikes
  1386. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  1387. ;; works for javac
  1388. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  1389. compilation-error-regexp-alist))
  1390. </pre></td>
  1391. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1392. </tr>
  1393. <tr>
  1394. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1395. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1396. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1397. </tr>
  1398. </table>
  1399. </div>
  1400. <p>Yet another alternative that preserves most of Ant's
  1401. formatting is to pipe Ant's output through the following Perl
  1402. script by Dirk-Willem van Gulik:</p>
  1403. <div align="left">
  1404. <table cellspacing="4" cellpadding="0" border="0">
  1405. <tr>
  1406. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1407. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1408. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1409. </tr>
  1410. <tr>
  1411. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1412. <td bgcolor="#ffffff"><pre>
  1413. #!/usr/bin/perl
  1414. #
  1415. # May 2001 dirkx@apache.org - remove any
  1416. # [foo] lines from the output; keeping
  1417. # spacing more or less there.
  1418. #
  1419. $|=1;
  1420. while(&lt;STDIN&gt;) {
  1421. if (s/^(\s+)\[(\w+)\]//) {
  1422. if ($2 ne $last) {
  1423. print &quot;$1\[$2\]&quot;;
  1424. $s = ' ' x length($2);
  1425. } else {
  1426. print &quot;$1 $s &quot;;
  1427. };
  1428. $last = $2;
  1429. };
  1430. print;
  1431. };
  1432. </pre></td>
  1433. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1434. </tr>
  1435. <tr>
  1436. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1437. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1438. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1439. </tr>
  1440. </table>
  1441. </div>
  1442. </blockquote>
  1443. </td></tr>
  1444. </table>
  1445. </a>
  1446. <a name="dtd">
  1447. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1448. <tr><td bgcolor="#828DA6">
  1449. <font color="#ffffff" face="arial,helvetica,sanserif">
  1450. <strong>
  1451. Is there a DTD that I can use to validate my build
  1452. files?
  1453. </strong>
  1454. </font>
  1455. </td></tr>
  1456. <tr><td>
  1457. <blockquote>
  1458. <p>An incomplete DTD can be created by the
  1459. <code>&lt;antstructure&gt;</code> task - but this one
  1460. has a few problems:</p>
  1461. <ul>
  1462. <li>It doesn't know about required attributes. Only
  1463. manual tweaking of this file can help here.</li>
  1464. <li>It is not complete - if you add new tasks via
  1465. <code>&lt;taskdef&gt;</code> it won't know about it. See
  1466. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  1467. page</a> by Michel Casabianca for a solution to this
  1468. problem. Note that the DTD you can download at this page
  1469. is based on Ant 0.3.1.</li>
  1470. <li>It may even be an invalid DTD. As Ant allows tasks
  1471. writers to define arbitrary elements, name collisions will
  1472. happen quite frequently - if your version of Ant contains
  1473. the optional <code>&lt;test&gt;</code> and
  1474. <code>&lt;junit&gt;</code> tasks, there are two XML
  1475. elements named <code>test</code> (the task and the nested child
  1476. element of <code>&lt;junit&gt;</code>) with different attribute
  1477. lists. This problem cannot be solved; DTDs don't give a
  1478. syntax rich enough to support this.</li>
  1479. </ul>
  1480. </blockquote>
  1481. </td></tr>
  1482. </table>
  1483. </a>
  1484. <a name="xml-entity-include">
  1485. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1486. <tr><td bgcolor="#828DA6">
  1487. <font color="#ffffff" face="arial,helvetica,sanserif">
  1488. <strong>
  1489. How do I include an XML snippet in my build file?
  1490. </strong>
  1491. </font>
  1492. </td></tr>
  1493. <tr><td>
  1494. <blockquote>
  1495. <p>You can use XML's way of including external files and let
  1496. the parser do the job for Ant:</p>
  1497. <div align="left">
  1498. <table cellspacing="4" cellpadding="0" border="0">
  1499. <tr>
  1500. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1501. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1502. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1503. </tr>
  1504. <tr>
  1505. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1506. <td bgcolor="#ffffff"><pre>
  1507. &lt;?xml version=&quot;1.0&quot;?&gt;
  1508. &lt;!DOCTYPE project [
  1509. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  1510. ]&gt;
  1511. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1512. &lt;target name=&quot;setup&quot;&gt;
  1513. ...
  1514. &lt;/target&gt;
  1515. &amp;common;
  1516. ...
  1517. &lt;/project&gt;
  1518. </pre></td>
  1519. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1520. </tr>
  1521. <tr>
  1522. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1523. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1524. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1525. </tr>
  1526. </table>
  1527. </div>
  1528. <p>will literally include the contents of <code>common.xml</code> where
  1529. you've placed the <code>&amp;common;</code> entity.</p>
  1530. <p>In combination with a DTD, this would look like this:</p>
  1531. <div align="left">
  1532. <table cellspacing="4" cellpadding="0" border="0">
  1533. <tr>
  1534. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1535. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1536. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1537. </tr>
  1538. <tr>
  1539. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1540. <td bgcolor="#ffffff"><pre>
  1541. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  1542. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  1543. ]&gt;
  1544. </pre></td>
  1545. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1546. </tr>
  1547. <tr>
  1548. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1549. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1550. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1551. </tr>
  1552. </table>
  1553. </div>
  1554. </blockquote>
  1555. </td></tr>
  1556. </table>
  1557. </a>
  1558. <a name="mail-logger">
  1559. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1560. <tr><td bgcolor="#828DA6">
  1561. <font color="#ffffff" face="arial,helvetica,sanserif">
  1562. <strong>
  1563. How do I send an email with the result of my build
  1564. process?
  1565. </strong>
  1566. </font>
  1567. </td></tr>
  1568. <tr><td>
  1569. <blockquote>
  1570. <p>If you are using a nightly build of Ant 1.5 after
  1571. 2001-12-14, you can use the built-in MailLogger:</p>
  1572. <div align="left">
  1573. <table cellspacing="4" cellpadding="0" border="0">
  1574. <tr>
  1575. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1576. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1577. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1578. </tr>
  1579. <tr>
  1580. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1581. <td bgcolor="#ffffff"><pre>
  1582. ant -logger org.apache.tools.ant.listener.MailLogger
  1583. </pre></td>
  1584. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1585. </tr>
  1586. <tr>
  1587. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1588. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1589. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1590. </tr>
  1591. </table>
  1592. </div>
  1593. <p>See the <a href="http://cvs.apache.org/viewcvs/~checkout~/jakarta-ant/docs/manual/listeners.html?content-type=text/html">Listeners
  1594. &amp; Loggers</a> documentation for details on the properties
  1595. required.</p>
  1596. <p>For older versions of Ant, you can use a custom
  1597. BuildListener that sends out an email
  1598. in the buildFinished() method. Will Glozer
  1599. &lt;will.glozer@jda.com&gt; has written such a listener based
  1600. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
  1601. The source is:</p>
  1602. <div align="left">
  1603. <table cellspacing="4" cellpadding="0" border="0">
  1604. <tr>
  1605. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1606. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1607. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1608. </tr>
  1609. <tr>
  1610. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1611. <td bgcolor="#ffffff"><pre>
  1612. import java.io.*;
  1613. import java.util.*;
  1614. import javax.mail.*;
  1615. import javax.mail.internet.*;
  1616. import org.apache.tools.ant.*;
  1617. /**
  1618. * A simple listener that waits for a build to finish and sends an email
  1619. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1620. * are fairly self explanatory.
  1621. *
  1622. * @author Will Glozer
  1623. * @version 1.05a 09/06/2000
  1624. */
  1625. public class BuildMonitor implements BuildListener {
  1626. protected Properties props;
  1627. /**
  1628. * Create a new BuildMonitor.
  1629. */
  1630. public BuildMonitor() throws Exception {
  1631. props = new Properties();
  1632. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1633. props.load(is);
  1634. is.close();
  1635. }
  1636. public void buildStarted(BuildEvent e) {
  1637. }
  1638. /**
  1639. * Determine the status of the build and the actions to follow, now that
  1640. * the build has completed.
  1641. *
  1642. * @param e Event describing the build status.
  1643. */
  1644. public void buildFinished(BuildEvent e) {
  1645. Throwable th = e.getException();
  1646. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1647. try {
  1648. String key = &quot;build.&quot; + status;
  1649. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1650. return;
  1651. }
  1652. Session session = Session.getDefaultInstance(props, null);
  1653. MimeMessage message = new MimeMessage(session);
  1654. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1655. props.getProperty(key + &quot;.email.to&quot;)));
  1656. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1657. BufferedReader br = new BufferedReader(new FileReader(
  1658. props.getProperty(&quot;build.log&quot;)));
  1659. StringWriter sw = new StringWriter();
  1660. String line = br.readLine();
  1661. while (line != null) {
  1662. sw.write(line);
  1663. sw.write(&quot;\n&quot;);
  1664. line = br.readLine();
  1665. }
  1666. br.close();
  1667. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1668. sw.close();
  1669. Transport transport = session.getTransport();
  1670. transport.connect();
  1671. transport.send(message);
  1672. transport.close();
  1673. } catch (Exception ex) {
  1674. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1675. ex.printStackTrace();
  1676. }
  1677. }
  1678. /**
  1679. * Parse a comma separated list of internet email addresses.
  1680. *
  1681. * @param s The list of addresses.
  1682. * @return Array of Addresses.
  1683. */
  1684. protected Address[] parseAddresses(String s) throws Exception {
  1685. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1686. Address[] addrs = new Address[st.countTokens()];
  1687. for (int i = 0; i &lt; addrs.length; i++) {
  1688. addrs[i] = new InternetAddress(st.nextToken());
  1689. }
  1690. return addrs;
  1691. }
  1692. public void messageLogged(BuildEvent e) {
  1693. }
  1694. public void targetStarted(BuildEvent e) {
  1695. }
  1696. public void targetFinished(BuildEvent e) {
  1697. }
  1698. public void taskStarted(BuildEvent e) {
  1699. }
  1700. public void taskFinished(BuildEvent e) {
  1701. }
  1702. }
  1703. </pre></td>
  1704. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1705. </tr>
  1706. <tr>
  1707. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1708. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1709. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1710. </tr>
  1711. </table>
  1712. </div>
  1713. <p>With a <code>monitor.properties</code> like this:</p>
  1714. <div align="left">
  1715. <table cellspacing="4" cellpadding="0" border="0">
  1716. <tr>
  1717. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1718. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1719. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1720. </tr>
  1721. <tr>
  1722. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1723. <td bgcolor="#ffffff"><pre>
  1724. # configuration for build monitor
  1725. mail.transport.protocol=smtp
  1726. mail.smtp.host=&lt;host&gt;
  1727. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1728. build.log=build.log
  1729. build.failed.notify=true
  1730. build.failed.email.to=will.glozer@jda.com
  1731. build.failed.email.subject=Nightly build failed!
  1732. build.succeeded.notify=true
  1733. build.succeeded.email.to=will.glozer@jda.com
  1734. build.succeeded.email.subject=Nightly build succeeded!
  1735. </pre></td>
  1736. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1737. </tr>
  1738. <tr>
  1739. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1740. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1741. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1742. </tr>
  1743. </table>
  1744. </div>
  1745. <p><code>monitor.properties</code> should be placed right next
  1746. to your compiled <code>BuildMonitor.class</code>. To use it,
  1747. invoke Ant like:</p>
  1748. <div align="left">
  1749. <table cellspacing="4" cellpadding="0" border="0">
  1750. <tr>
  1751. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1752. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1753. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1754. </tr>
  1755. <tr>
  1756. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1757. <td bgcolor="#ffffff"><pre>
  1758. ant -listener BuildMonitor -logfile build.log
  1759. </pre></td>
  1760. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1761. </tr>
  1762. <tr>
  1763. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1764. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1765. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1766. </tr>
  1767. </table>
  1768. </div>
  1769. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1770. <code>activation.jar</code> from the
  1771. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1772. Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
  1773. </blockquote>
  1774. </td></tr>
  1775. </table>
  1776. </a>
  1777. <a name="listener-properties">
  1778. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1779. <tr><td bgcolor="#828DA6">
  1780. <font color="#ffffff" face="arial,helvetica,sanserif">
  1781. <strong>
  1782. How do I get at the properties that Ant was running
  1783. with from inside BuildListener?
  1784. </strong>
  1785. </font>
  1786. </td></tr>
  1787. <tr><td>
  1788. <blockquote>
  1789. <p>You can get at a hashtable with all the properties that Ant
  1790. has been using through the BuildEvent parameter. For
  1791. example:</p>
  1792. <div align="left">
  1793. <table cellspacing="4" cellpadding="0" border="0">
  1794. <tr>
  1795. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1796. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1797. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1798. </tr>
  1799. <tr>
  1800. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1801. <td bgcolor="#ffffff"><pre>
  1802. public void buildFinished(BuildEvent e) {
  1803. Hashtable table = e.getProject().getProperties();
  1804. String buildpath = (String)table.get(&quot;build.path&quot;);
  1805. ...
  1806. }
  1807. </pre></td>
  1808. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1809. </tr>
  1810. <tr>
  1811. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1812. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  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. </tr>
  1815. </table>
  1816. </div>
  1817. <p>This is more accurate than just reading the same property
  1818. files that your project does, since it will give the correct
  1819. results for properties that were specified on the Ant command line.</p>
  1820. </blockquote>
  1821. </td></tr>
  1822. </table>
  1823. </a>
  1824. <a name="remove-cr">
  1825. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1826. <tr><td bgcolor="#828DA6">
  1827. <font color="#ffffff" face="arial,helvetica,sanserif">
  1828. <strong>
  1829. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  1830. 1.3 on Unix
  1831. </strong>
  1832. </font>
  1833. </td></tr>
  1834. <tr><td>
  1835. <blockquote>
  1836. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1837. has DOS instead of Unix line endings; you must remove the
  1838. carriage-return characters from this file. This can be done by
  1839. using Ant's <code>&lt;fixcrlf&gt;</code> task
  1840. or something like:</p>
  1841. <div align="left">
  1842. <table cellspacing="4" cellpadding="0" border="0">
  1843. <tr>
  1844. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1845. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1846. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1847. </tr>
  1848. <tr>
  1849. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1850. <td bgcolor="#ffffff"><pre>
  1851. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1852. mv /tmp/foo $ANT_HOME/bin/antRun
  1853. </pre></td>
  1854. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1855. </tr>
  1856. <tr>
  1857. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1858. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1859. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1860. </tr>
  1861. </table>
  1862. </div>
  1863. </blockquote>
  1864. </td></tr>
  1865. </table>
  1866. </a>
  1867. <a name="javadoc-cannot-execute">
  1868. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1869. <tr><td bgcolor="#828DA6">
  1870. <font color="#ffffff" face="arial,helvetica,sanserif">
  1871. <strong>
  1872. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1873. </strong>
  1874. </font>
  1875. </td></tr>
  1876. <tr><td>
  1877. <blockquote>
  1878. <p>There is a bug in the Solaris reference implementation of
  1879. 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>).
  1880. This also appears to be true under Linux. Moving the JDK to
  1881. the front of the PATH fixes the problem.</p>
  1882. </blockquote>
  1883. </td></tr>
  1884. </table>
  1885. </a>
  1886. <a name="delegating-classloader">
  1887. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1888. <tr><td bgcolor="#828DA6">
  1889. <font color="#ffffff" face="arial,helvetica,sanserif">
  1890. <strong>
  1891. &lt;style&gt; or &lt;junit&gt; ignores my
  1892. &lt;classpath&gt;
  1893. </strong>
  1894. </font>
  1895. </td></tr>
  1896. <tr><td>
  1897. <blockquote>
  1898. <p>These tasks don't ignore your classpath setting, you
  1899. are facing a common problem with delegating classloaders.</p>
  1900. <p>First of all let's state that Ant adds all
  1901. <code>.jar</code> files from <code>ANT_HOME/lib</code> to
  1902. <code>CLASSPATH</code>, therefore "in
  1903. <code>CLASSPATH</code>" shall mean "either in your
  1904. <code>CLASSPATH</code> environment variable or
  1905. <code>ANT_HOME/lib</code>" for the rest of this
  1906. answer.</p>
  1907. <p>This question collects a common type of problem: A task
  1908. needs an external library and it has a nested classpath
  1909. element so that you can point it to this external library, but
  1910. that doesn't work unless you put the external library into the
  1911. <code>CLASSPATH</code>.</p>
  1912. <p>The root of the problem is that the class that needs the
  1913. external library is on the <code>CLASSPATH</code>.</p>
  1914. <p>When you specify a nested <code>&lt;classpath&gt;</code> in
  1915. Ant, Ant creates a new class loader that uses the path you
  1916. have specified. It then tries to load additional classes from
  1917. this classloader.</p>
  1918. <p>In most cases - for example the two cases above - Ant
  1919. doesn't load the external library directly, it is the loaded
  1920. class that does so.</p>
  1921. <p>In the case of <code>&lt;junit&gt;</code> it is the task
  1922. implementation itself and in the case of
  1923. <code>&lt;style&gt;</code> it is the implementation of the
  1924. <code>org.apache.tools.ant.taskdefs.XSLTLiaison</code>
  1925. class.</p>
  1926. <p>Ant's class loader implementation uses Java's
  1927. 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>
  1928. the paragraph</p>
  1929. <blockquote>The <code>ClassLoader</code> class uses a
  1930. delegation model to search for classes and resources. Each
  1931. instance of <code>ClassLoader</code> has an associated parent
  1932. class loader. When called upon to find a class or resource, a
  1933. <code>ClassLoader</code> instance will delegate the search for
  1934. the class or resource to its parent class loader before
  1935. attempting to find the class or resource itself. The virtual
  1936. machine's built-in class loader, called the bootstrap
  1937. class loader, does not itself have a parent but may serve as
  1938. the parent of a <code>ClassLoader</code>
  1939. instance.</blockquote>
  1940. <p>This means, Ant's class loader will consult the
  1941. bootstrap class loader first, which tries to load classes from
  1942. <code>CLASSPATH</code>. The bootstrap class loader
  1943. doesn't know anything about Ant's class loader or
  1944. even the path you have specified.</p>
  1945. <p>If the bootstrap class loader can load the class Ant has
  1946. asked it to load, this class will try to load the external
  1947. library from <code>CLASSPATH</code> as well - it doesn't
  1948. know anything else - and will not find it unless the library
  1949. is in <code>CLASSPATH</code> as well.</p>
  1950. <p>To solve this, you have two major options:</p>
  1951. <ol>
  1952. <li>put all external libraries you need in
  1953. <code>CLASSPATH</code> as well this is not what you want,
  1954. otherwise you wouldn't have found this FAQ entry.</li>
  1955. <li>remove the class that loads the external library from
  1956. the <code>CLASSPATH</code>.</li>
  1957. </ol>
  1958. <p>The easiest way to do this is to remove
  1959. <code>optional.jar</code> from <code>ANT_HOME/lib</code>. If
  1960. you do so, you will have to <code>&lt;taskdef&gt;</code> all
  1961. optional tasks and use nested <code>&lt;classpath&gt;</code>
  1962. elements in the <code>&lt;taskdef&gt;</code> tasks that point
  1963. to the new location of <code>optional.jar</code>. Also,
  1964. don't forget to add the new location of
  1965. <code>optional.jar</code> to the
  1966. <code>&lt;classpath&gt;</code> of your
  1967. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code>
  1968. task.</p>
  1969. <p>If you want to avoid to <code>&lt;taskdef&gt;</code> all
  1970. optional tasks you need, the only other option is to remove
  1971. the classes that should not be loaded via the bootstrap class
  1972. loader from <code>optional.jar</code> and put them into a
  1973. separate archive. Add this separate archive to the
  1974. <code>&lt;classpath&gt;</code> of your
  1975. <code>&lt;style&gt;</code> or <code>&lt;junit&gt;</code> task
  1976. - and make sure the separate archive is not in
  1977. <code>CLASSPATH</code>.</p>
  1978. <p>In the case of <code>&lt;junit&gt;</code> you'd have
  1979. to remove all classes that are in the
  1980. <code>org/apache/tools/ant/taskdefs/optional/junit</code>
  1981. directory, in the <code>&lt;style&gt;</code> case it is one of
  1982. the <code>*Liaison</code> classes in
  1983. <code>org/apache/tools/ant/taskdefs/optional</code>.</p>
  1984. <p>If you use the option to break up <code>optional.jar</code>
  1985. for <code>&lt;junit&gt;</code>, you still have to use a
  1986. <code>&lt;taskdef&gt;</code> with a nested
  1987. <code>&lt;classpath&gt;</code> to define the junit task.</p>
  1988. </blockquote>
  1989. </td></tr>
  1990. </table>
  1991. </a>
  1992. <a name="1.5-cygwin-sh">
  1993. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1994. <tr><td bgcolor="#828DA6">
  1995. <font color="#ffffff" face="arial,helvetica,sanserif">
  1996. <strong>
  1997. The <code>ant</code> wrapper script of Ant 1.5 fails
  1998. for Cygwin if <code>ANT_HOME</code> is set to a Windows style
  1999. path.
  2000. </strong>
  2001. </font>
  2002. </td></tr>
  2003. <tr><td>
  2004. <blockquote>
  2005. <p>This problem has been reported only hours after Ant 1.5 has
  2006. been released, see <a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10664">Bug
  2007. 10664</a> and all it's duplicates.</p>
  2008. <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>.
  2009. Simply replace your script with this version.</p>
  2010. </blockquote>
  2011. </td></tr>
  2012. </table>
  2013. </a>
  2014. </blockquote>
  2015. </td></tr>
  2016. </table>
  2017. </td>
  2018. </tr>
  2019. <!-- FOOTER -->
  2020. <tr><td colspan="2">
  2021. <hr noshade="" size="1"/>
  2022. </td></tr>
  2023. <tr><td colspan="2">
  2024. <div align="center"><font color="#525D76" size="-1"><em>
  2025. Copyright &#169; 2000-2002, Apache Software Foundation
  2026. </em></font></div>
  2027. </td></tr>
  2028. </table>
  2029. </body>
  2030. </html>
  2031. <!-- end the processing -->