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

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