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

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