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

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