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

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