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

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