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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  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>General</strong>
  91. </font>
  92. </td></tr>
  93. <tr><td>
  94. <blockquote>
  95. <ul>
  96. <li><a href="#what-is-ant">
  97. What is Apache Ant?
  98. </a></li>
  99. <li><a href="#ant-name">
  100. Why do you call it Ant?
  101. </a></li>
  102. <li><a href="#history">
  103. Tell us a little bit about Ant's history.
  104. </a></li>
  105. </ul>
  106. </blockquote>
  107. </td></tr>
  108. </table>
  109. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  110. <tr><td bgcolor="#828DA6">
  111. <font color="#ffffff" face="arial,helvetica,sanserif">
  112. <strong>Installation</strong>
  113. </font>
  114. </td></tr>
  115. <tr><td>
  116. <blockquote>
  117. <ul>
  118. <li><a href="#no-gnu-tar">
  119. I get checksum errors when I try to extract the
  120. <code>tar.gz</code> distribution file. Why?
  121. </a></li>
  122. </ul>
  123. </blockquote>
  124. </td></tr>
  125. </table>
  126. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  127. <tr><td bgcolor="#828DA6">
  128. <font color="#ffffff" face="arial,helvetica,sanserif">
  129. <strong>Using Ant</strong>
  130. </font>
  131. </td></tr>
  132. <tr><td>
  133. <blockquote>
  134. <ul>
  135. <li><a href="#always-recompiles">
  136. Why does Ant always recompile all my Java files?
  137. </a></li>
  138. <li><a href="#passing-cli-args">
  139. How do I pass parameters from the command line to my
  140. build file?
  141. </a></li>
  142. <li><a href="#jikes-switches">
  143. How can I use Jikes specific command line
  144. switches?
  145. </a></li>
  146. <li><a href="#shell-redirect-1">
  147. How do I include a &lt; character in my command line arguments?
  148. </a></li>
  149. <li><a href="#shell-redirect-2">
  150. How do I redirect standard input or standard output
  151. in the <code>&lt;exec&gt;</code> task?
  152. </a></li>
  153. <li><a href="#defaultexcludes">
  154. I've made a &lt;delete&gt; task to delete unwanted
  155. sourcesafe control files (CVS files, editor backup files), but
  156. it doesn't seem to work. The files never get deleted. What's
  157. wrong?
  158. </a></li>
  159. </ul>
  160. </blockquote>
  161. </td></tr>
  162. </table>
  163. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  164. <tr><td bgcolor="#828DA6">
  165. <font color="#ffffff" face="arial,helvetica,sanserif">
  166. <strong>Ant and IDEs/Editors</strong>
  167. </font>
  168. </td></tr>
  169. <tr><td>
  170. <blockquote>
  171. <ul>
  172. <li><a href="#integration">
  173. Is Ant supported by my IDE/Editor?
  174. </a></li>
  175. <li><a href="#emacs-mode">
  176. Why doesn't (X)Emacs/vi/MacOS X's project builder
  177. parse the error messages generated by Ant correctly?
  178. </a></li>
  179. </ul>
  180. </blockquote>
  181. </td></tr>
  182. </table>
  183. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  184. <tr><td bgcolor="#828DA6">
  185. <font color="#ffffff" face="arial,helvetica,sanserif">
  186. <strong>Advanced issues</strong>
  187. </font>
  188. </td></tr>
  189. <tr><td>
  190. <blockquote>
  191. <ul>
  192. <li><a href="#dtd">
  193. Is there a DTD that I can use to validate my build
  194. files?
  195. </a></li>
  196. <li><a href="#xml-entity-include">
  197. How do I include an XML snippet in my build file?
  198. </a></li>
  199. <li><a href="#mail-logger">
  200. How do I send an email with the result of my build
  201. process?
  202. </a></li>
  203. </ul>
  204. </blockquote>
  205. </td></tr>
  206. </table>
  207. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  208. <tr><td bgcolor="#828DA6">
  209. <font color="#ffffff" face="arial,helvetica,sanserif">
  210. <strong>Known problems</strong>
  211. </font>
  212. </td></tr>
  213. <tr><td>
  214. <blockquote>
  215. <ul>
  216. <li><a href="#remove-cr">
  217. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  218. 1.3 on Unix
  219. </a></li>
  220. <li><a href="#javadoc-cannot-execute">
  221. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  222. </a></li>
  223. </ul>
  224. </blockquote>
  225. </td></tr>
  226. </table>
  227. </blockquote>
  228. </td></tr>
  229. </table>
  230. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  231. <tr><td bgcolor="#525D76">
  232. <font color="#ffffff" face="arial,helvetica,sanserif">
  233. <strong>Answers</strong>
  234. </font>
  235. </td></tr>
  236. <tr><td>
  237. <blockquote>
  238. <a name="what-is-ant">
  239. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  240. <tr><td bgcolor="#828DA6">
  241. <font color="#ffffff" face="arial,helvetica,sanserif">
  242. <strong>
  243. What is Apache Ant?
  244. </strong>
  245. </font>
  246. </td></tr>
  247. <tr><td>
  248. <blockquote>
  249. <p> Ant is a Java based build tool. In theory it is kind of
  250. like "make" without makes wrinkles and with the full
  251. portability of pure Java code.</p>
  252. </blockquote>
  253. </td></tr>
  254. </table>
  255. </a>
  256. <a name="ant-name">
  257. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  258. <tr><td bgcolor="#828DA6">
  259. <font color="#ffffff" face="arial,helvetica,sanserif">
  260. <strong>
  261. Why do you call it Ant?
  262. </strong>
  263. </font>
  264. </td></tr>
  265. <tr><td>
  266. <blockquote>
  267. <p>According to Ant's original author James Duncan
  268. Davidson, the name is an acronym for "Another Neat
  269. Tool".</p>
  270. <p>Later explanations go along the lines of "Ants are
  271. doing an extremely good job at building things" or
  272. "Ants are very small and can carry a weight a dozen times
  273. of their own" - describing what Ant is intended to
  274. be.</p>
  275. </blockquote>
  276. </td></tr>
  277. </table>
  278. </a>
  279. <a name="history">
  280. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  281. <tr><td bgcolor="#828DA6">
  282. <font color="#ffffff" face="arial,helvetica,sanserif">
  283. <strong>
  284. Tell us a little bit about Ant's history.
  285. </strong>
  286. </font>
  287. </td></tr>
  288. <tr><td>
  289. <blockquote>
  290. <p>Initially Ant was part of the Tomcat code base when it was
  291. donated to the Apache Software Foundation - it has been
  292. created by James Duncan Davidson, who also is the original
  293. author of Tomcat. Ant was there to build Tomcat, nothing
  294. else.</p>
  295. <p>Soon thereafter several open source Java projects realized
  296. that Ant could solve the problems they had with makefiles.
  297. Starting with the projects hosted at Jakarta and the old Java
  298. Apache project, Ant spread like a virus and now is the build
  299. tool of choice for a lot of projects.</p>
  300. <p>In January 2000 Ant was moved to a separate CVS module and
  301. was promoted to a project of its own, independent of
  302. Tomcat. Ant became Apache Ant.</p>
  303. <p>The first version of Ant that was exposed a lager audience
  304. was the one that shipped with Tomcat's 3.1 release on 19 April
  305. 2000. This version has later been referenced to as Ant
  306. 0.3.1.</p>
  307. <p>The first official release of Ant as a stand alone product was
  308. Ant 1.1 released on 19 July 2000. The complete release
  309. history:</p>
  310. <table>
  311. <tr>
  312. <td bgcolor="#039acc" colspan="" rowspan=""
  313. valign="top" align="left">
  314. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  315. Ant Version
  316. </font>
  317. </td>
  318. <td bgcolor="#039acc" colspan="" rowspan=""
  319. valign="top" align="left">
  320. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  321. Release Date
  322. </font>
  323. </td>
  324. </tr>
  325. <tr>
  326. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  327. valign="top" align="left">
  328. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  329. 1.1
  330. </font>
  331. </td>
  332. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  333. valign="top" align="left">
  334. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  335. 19 July 2000
  336. </font>
  337. </td>
  338. </tr>
  339. <tr>
  340. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  341. valign="top" align="left">
  342. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  343. 1.2
  344. </font>
  345. </td>
  346. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  347. valign="top" align="left">
  348. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  349. 24 October 2000
  350. </font>
  351. </td>
  352. </tr>
  353. <tr>
  354. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  355. valign="top" align="left">
  356. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  357. 1.3
  358. </font>
  359. </td>
  360. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  361. valign="top" align="left">
  362. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  363. 3 March 2001
  364. </font>
  365. </td>
  366. </tr>
  367. <tr>
  368. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  369. valign="top" align="left">
  370. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  371. 1.4
  372. </font>
  373. </td>
  374. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  375. valign="top" align="left">
  376. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  377. 3 September 2001
  378. </font>
  379. </td>
  380. </tr>
  381. <tr>
  382. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  383. valign="top" align="left">
  384. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  385. 1.4.1
  386. </font>
  387. </td>
  388. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  389. valign="top" align="left">
  390. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  391. 11 October 2001
  392. </font>
  393. </td>
  394. </tr>
  395. </table>
  396. </blockquote>
  397. </td></tr>
  398. </table>
  399. </a>
  400. <a name="no-gnu-tar">
  401. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  402. <tr><td bgcolor="#828DA6">
  403. <font color="#ffffff" face="arial,helvetica,sanserif">
  404. <strong>
  405. I get checksum errors when I try to extract the
  406. <code>tar.gz</code> distribution file. Why?
  407. </strong>
  408. </font>
  409. </td></tr>
  410. <tr><td>
  411. <blockquote>
  412. <p>Ant's distribution contains file names that are longer
  413. than 100 characters, which is not supported by the standard
  414. tar file format. Several different implementations of tar use
  415. different and incompatible ways to work around this
  416. restriction.</p>
  417. <p>Ant's &lt;tar&gt; task can create tar archives that use
  418. the GNU tar extension, and this has been used when putting
  419. together the distribution. If you are using a different
  420. version of tar (for example, the one shipping with Solaris),
  421. you cannot use it to extract the archive.</p>
  422. <p>The solution is to either install GNU tar, which can be
  423. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
  424. or use the zip archive instead (you can extract it using
  425. <code>jar xf</code>).</p>
  426. </blockquote>
  427. </td></tr>
  428. </table>
  429. </a>
  430. <a name="always-recompiles">
  431. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  432. <tr><td bgcolor="#828DA6">
  433. <font color="#ffffff" face="arial,helvetica,sanserif">
  434. <strong>
  435. Why does Ant always recompile all my Java files?
  436. </strong>
  437. </font>
  438. </td></tr>
  439. <tr><td>
  440. <blockquote>
  441. <p>In order to find out which files should be compiled, Ant
  442. compares the timestamps of the source files to those of the
  443. resulting <code>.class</code> files. Opening all source files
  444. to find out which package they belong to would be very
  445. inefficient - instead of this, Ant expects you to place your
  446. source files in a directory hierarchy that mirrors your
  447. package hierarchy and to point Ant to the root of this
  448. directory tree with the <code>srcdir</code> attribute.</p>
  449. <p>Say you have <code>&lt;javac srcdir="src"
  450. destdir="dest" /&gt;</code>. If Ant finds a file
  451. <code>src/a/b/C.java</code> it expects it to be in package
  452. <code>a.b</code> so that the resulting <code>.class</code>
  453. file is going to be <code>dest/a/b/C.class</code>.</p>
  454. <p>If your setup is different, Ant's heuristic won't work and
  455. it will recompile classes that are up to date. Ant is not the
  456. only tool, that expects a source tree layout like this.</p>
  457. </blockquote>
  458. </td></tr>
  459. </table>
  460. </a>
  461. <a name="passing-cli-args">
  462. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  463. <tr><td bgcolor="#828DA6">
  464. <font color="#ffffff" face="arial,helvetica,sanserif">
  465. <strong>
  466. How do I pass parameters from the command line to my
  467. build file?
  468. </strong>
  469. </font>
  470. </td></tr>
  471. <tr><td>
  472. <blockquote>
  473. <p>Use properties: <code>ant
  474. -D&lt;name&gt;=&lt;value&gt;</code> lets you define values for
  475. properties. These can then be used within your build file as
  476. any normal property: <code>${&lt;name&gt;}</code> will put in
  477. <code>&lt;value&gt;</code>.</p>
  478. </blockquote>
  479. </td></tr>
  480. </table>
  481. </a>
  482. <a name="jikes-switches">
  483. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  484. <tr><td bgcolor="#828DA6">
  485. <font color="#ffffff" face="arial,helvetica,sanserif">
  486. <strong>
  487. How can I use Jikes specific command line
  488. switches?
  489. </strong>
  490. </font>
  491. </td></tr>
  492. <tr><td>
  493. <blockquote>
  494. <p>A couple of switches are supported via magic
  495. properties:</p>
  496. <table>
  497. <tr>
  498. <td bgcolor="#039acc" colspan="" rowspan=""
  499. valign="top" align="left">
  500. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  501. switch
  502. </font>
  503. </td>
  504. <td bgcolor="#039acc" colspan="" rowspan=""
  505. valign="top" align="left">
  506. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  507. property
  508. </font>
  509. </td>
  510. <td bgcolor="#039acc" colspan="" rowspan=""
  511. valign="top" align="left">
  512. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  513. default
  514. </font>
  515. </td>
  516. </tr>
  517. <tr>
  518. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  519. valign="top" align="left">
  520. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  521. +E
  522. </font>
  523. </td>
  524. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  525. valign="top" align="left">
  526. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  527. build.compiler.emacs
  528. </font>
  529. </td>
  530. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  531. valign="top" align="left">
  532. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  533. false == not set
  534. </font>
  535. </td>
  536. </tr>
  537. <tr>
  538. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  539. valign="top" align="left">
  540. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  541. +P
  542. </font>
  543. </td>
  544. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  545. valign="top" align="left">
  546. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  547. build.compiler.pedantic
  548. </font>
  549. </td>
  550. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  551. valign="top" align="left">
  552. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  553. false == not set
  554. </font>
  555. </td>
  556. </tr>
  557. <tr>
  558. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  559. valign="top" align="left">
  560. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  561. +F
  562. </font>
  563. </td>
  564. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  565. valign="top" align="left">
  566. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  567. build.compiler.fulldepend
  568. </font>
  569. </td>
  570. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  571. valign="top" align="left">
  572. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  573. false == not set
  574. </font>
  575. </td>
  576. </tr>
  577. <tr>
  578. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  579. valign="top" align="left">
  580. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  581. <strong>only for Ant &lt; 1.4, replaced by the nowarn
  582. attribute of javac after that</strong> -nowarn
  583. </font>
  584. </td>
  585. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  586. valign="top" align="left">
  587. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  588. build.compiler.warnings
  589. </font>
  590. </td>
  591. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  592. valign="top" align="left">
  593. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  594. true == not set
  595. </font>
  596. </td>
  597. </tr>
  598. </table>
  599. </blockquote>
  600. </td></tr>
  601. </table>
  602. </a>
  603. <a name="shell-redirect-1">
  604. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  605. <tr><td bgcolor="#828DA6">
  606. <font color="#ffffff" face="arial,helvetica,sanserif">
  607. <strong>
  608. How do I include a &lt; character in my command line arguments?
  609. </strong>
  610. </font>
  611. </td></tr>
  612. <tr><td>
  613. <blockquote>
  614. <p>The short answer is "Use <code>&amp;lt;</code>".</p>
  615. <p>The long answer is, that this probably won't do what you
  616. want anyway, see <a href="#shell-redirect-2">the next
  617. section</a>.</p>
  618. </blockquote>
  619. </td></tr>
  620. </table>
  621. </a>
  622. <a name="shell-redirect-2">
  623. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  624. <tr><td bgcolor="#828DA6">
  625. <font color="#ffffff" face="arial,helvetica,sanserif">
  626. <strong>
  627. How do I redirect standard input or standard output
  628. in the <code>&lt;exec&gt;</code> task?
  629. </strong>
  630. </font>
  631. </td></tr>
  632. <tr><td>
  633. <blockquote>
  634. <p>Say you want to redirect the standard input stream of the
  635. <code>cat</code> command to read from a file, something
  636. like</p>
  637. <div align="left">
  638. <table cellspacing="4" cellpadding="0" border="0">
  639. <tr>
  640. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  641. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  642. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  643. </tr>
  644. <tr>
  645. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  646. <td bgcolor="#ffffff"><pre>
  647. shell-prompt&gt; cat &lt; foo
  648. </pre></td>
  649. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  650. </tr>
  651. <tr>
  652. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  653. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  654. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  655. </tr>
  656. </table>
  657. </div>
  658. <p>and try to translate it into</p>
  659. <div align="left">
  660. <table cellspacing="4" cellpadding="0" border="0">
  661. <tr>
  662. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  663. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  664. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  665. </tr>
  666. <tr>
  667. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  668. <td bgcolor="#ffffff"><pre>
  669. &lt;exec executable=&quot;cat&quot;&gt;
  670. &lt;arg value=&quot;&amp;lt;&quot; /&gt;
  671. &lt;arg value=&quot;foo&quot; /&gt;
  672. &lt;/exec&gt;
  673. </pre></td>
  674. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  675. </tr>
  676. <tr>
  677. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  678. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  679. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  680. </tr>
  681. </table>
  682. </div>
  683. <p>This will not do what you expect. The input-redirection is
  684. performed by your shell, not the command itself, so this
  685. should read:</p>
  686. <div align="left">
  687. <table cellspacing="4" cellpadding="0" border="0">
  688. <tr>
  689. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  690. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  691. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  692. </tr>
  693. <tr>
  694. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  695. <td bgcolor="#ffffff"><pre>
  696. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  697. &lt;arg value=&quot;-c&quot; /&gt;
  698. &lt;arg value=&quot;cat &amp;lt; foo&quot; /&gt;
  699. &lt;/exec&gt;
  700. </pre></td>
  701. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  702. </tr>
  703. <tr>
  704. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  705. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  706. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  707. </tr>
  708. </table>
  709. </div>
  710. <p>Note, that you must use the <code>value</code> attribute of
  711. <code>&lt;arg&gt;</code> in the last element.</p>
  712. </blockquote>
  713. </td></tr>
  714. </table>
  715. </a>
  716. <a name="defaultexcludes">
  717. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  718. <tr><td bgcolor="#828DA6">
  719. <font color="#ffffff" face="arial,helvetica,sanserif">
  720. <strong>
  721. I've made a &lt;delete&gt; task to delete unwanted
  722. sourcesafe control files (CVS files, editor backup files), but
  723. it doesn't seem to work. The files never get deleted. What's
  724. wrong?
  725. </strong>
  726. </font>
  727. </td></tr>
  728. <tr><td>
  729. <blockquote>
  730. <p>This is probably happening because by default, Ant excludes
  731. SourceSafe control files (<code>vssver.scc</code>) and other
  732. files from FileSets.</p>
  733. <p>Here's what you probably did:</p>
  734. <div align="left">
  735. <table cellspacing="4" cellpadding="0" border="0">
  736. <tr>
  737. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  738. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  739. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  740. </tr>
  741. <tr>
  742. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  743. <td bgcolor="#ffffff"><pre>
  744. &lt;delete&gt;
  745. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  746. &lt;/delete&gt;
  747. </pre></td>
  748. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  749. </tr>
  750. <tr>
  751. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  752. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  753. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  754. </tr>
  755. </table>
  756. </div>
  757. <p>You need to switch off the default exclusions and it will work:</p>
  758. <div align="left">
  759. <table cellspacing="4" cellpadding="0" border="0">
  760. <tr>
  761. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  762. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  763. <td bgcolor="#023264" width="1" height="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"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  767. <td bgcolor="#ffffff"><pre>
  768. &lt;delete&gt;
  769. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  770. defaultexcludes=&quot;no&quot;/&gt;
  771. &lt;/delete&gt;
  772. </pre></td>
  773. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  774. </tr>
  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. </table>
  781. </div>
  782. <p>For a complete listing of the patterns thate are excluded
  783. by default, see <a href="manual/dirtasks.html">the user
  784. manual</a>.</p>
  785. </blockquote>
  786. </td></tr>
  787. </table>
  788. </a>
  789. <a name="integration">
  790. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  791. <tr><td bgcolor="#828DA6">
  792. <font color="#ffffff" face="arial,helvetica,sanserif">
  793. <strong>
  794. Is Ant supported by my IDE/Editor?
  795. </strong>
  796. </font>
  797. </td></tr>
  798. <tr><td>
  799. <blockquote>
  800. <p>See the <a href="external.html#IDE and Editor Integration">section
  801. on IDE integration</a> on our external tools page.</p>
  802. </blockquote>
  803. </td></tr>
  804. </table>
  805. </a>
  806. <a name="emacs-mode">
  807. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  808. <tr><td bgcolor="#828DA6">
  809. <font color="#ffffff" face="arial,helvetica,sanserif">
  810. <strong>
  811. Why doesn't (X)Emacs/vi/MacOS X's project builder
  812. parse the error messages generated by Ant correctly?
  813. </strong>
  814. </font>
  815. </td></tr>
  816. <tr><td>
  817. <blockquote>
  818. <p>Ant adds a "banner" with the name of the current
  819. task in front of all messages - and there are no built-in
  820. regular expressions in your Editor that would account for
  821. this.</p>
  822. <p>You can disable this banner by invoking Ant with the
  823. <code>-emacs</code> switch. Alternatively you can add the
  824. following snippet to your <code>.emacs</code> to make Emacs
  825. understand Ant's output.</p>
  826. <div align="left">
  827. <table cellspacing="4" cellpadding="0" border="0">
  828. <tr>
  829. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  830. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  831. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  832. </tr>
  833. <tr>
  834. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  835. <td bgcolor="#ffffff"><pre>
  836. (require 'compile)
  837. (setq compilation-error-regexp-alist
  838. (append (list
  839. ;; works for jikes
  840. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  841. ;; works for javac
  842. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  843. compilation-error-regexp-alist))
  844. </pre></td>
  845. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  846. </tr>
  847. <tr>
  848. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  849. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  850. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  851. </tr>
  852. </table>
  853. </div>
  854. <p>Yet another alternative that preserves most of Ant's
  855. formatting is to pipe Ant's output through the following Perl
  856. script by Dirk-Willem van Gulik:</p>
  857. <div align="left">
  858. <table cellspacing="4" cellpadding="0" border="0">
  859. <tr>
  860. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  861. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  862. <td bgcolor="#023264" width="1" height="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"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  866. <td bgcolor="#ffffff"><pre>
  867. #!/usr/bin/perl
  868. #
  869. # May 2001 dirkx@apache.org - remove any
  870. # [foo] lines from the output; keeping
  871. # spacing more or less there.
  872. #
  873. $|=1;
  874. while(&lt;STDIN&gt;) {
  875. if (s/^(\s+)\[(\w+)\]//) {
  876. if ($2 ne $last) {
  877. print &quot;$1\[$2\]&quot;;
  878. $s = ' ' x length($2);
  879. } else {
  880. print &quot;$1 $s &quot;;
  881. };
  882. $last = $2;
  883. };
  884. print;
  885. };
  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. </blockquote>
  897. </td></tr>
  898. </table>
  899. </a>
  900. <a name="dtd">
  901. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  902. <tr><td bgcolor="#828DA6">
  903. <font color="#ffffff" face="arial,helvetica,sanserif">
  904. <strong>
  905. Is there a DTD that I can use to validate my build
  906. files?
  907. </strong>
  908. </font>
  909. </td></tr>
  910. <tr><td>
  911. <blockquote>
  912. <p>An incomplete DTD can be created by the
  913. <code>&lt;antstructure&gt;</code> task - but this one
  914. has a few problems:</p>
  915. <ul>
  916. <li>It doesn't know about required attributes. Only
  917. manual tweaking of this file can help here.</li>
  918. <li>It is not complete - if you add new tasks via
  919. <code>&lt;taskdef&gt;</code> it won't know about it. See
  920. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  921. page</a> by Michel Casabianca for a solution to this
  922. problem. Note that the DTD you can download at this page
  923. is based on Ant 0.3.1.</li>
  924. <li>It may even be an invalid DTD. As Ant allows tasks
  925. writers to define arbitrary elements, name collisions will
  926. happen quite frequently - if your version of Ant contains
  927. the optional <code>&lt;test&gt;</code> and
  928. <code>&lt;junit&gt;</code> tasks, there are two XML
  929. elements named test (the task and the nested child element
  930. of <code>&lt;junit&gt;</code>) with different attribute
  931. lists. This problem cannot be solved, DTDs don't give a
  932. syntax rich enough to support this.</li>
  933. </ul>
  934. </blockquote>
  935. </td></tr>
  936. </table>
  937. </a>
  938. <a name="xml-entity-include">
  939. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  940. <tr><td bgcolor="#828DA6">
  941. <font color="#ffffff" face="arial,helvetica,sanserif">
  942. <strong>
  943. How do I include an XML snippet in my build file?
  944. </strong>
  945. </font>
  946. </td></tr>
  947. <tr><td>
  948. <blockquote>
  949. <p>You can use XML's way of including external files and let
  950. the parser do the job for Ant:</p>
  951. <div align="left">
  952. <table cellspacing="4" cellpadding="0" border="0">
  953. <tr>
  954. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  955. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  956. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  957. </tr>
  958. <tr>
  959. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  960. <td bgcolor="#ffffff"><pre>
  961. &lt;?xml version=&quot;1.0&quot;?&gt;
  962. &lt;!DOCTYPE project [
  963. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  964. ]&gt;
  965. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  966. &lt;target name=&quot;setup&quot;&gt;
  967. ...
  968. &lt;/target&gt;
  969. &amp;common;
  970. ...
  971. &lt;/project&gt;
  972. </pre></td>
  973. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  974. </tr>
  975. <tr>
  976. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  977. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  978. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  979. </tr>
  980. </table>
  981. </div>
  982. <p>will literally include the contents of <code>common.xml</code> where
  983. you've placed the <code>&amp;common;</code> entity.</p>
  984. <p>In combination with a DTD, this would look like this:</p>
  985. <div align="left">
  986. <table cellspacing="4" cellpadding="0" border="0">
  987. <tr>
  988. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  989. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  990. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  991. </tr>
  992. <tr>
  993. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  994. <td bgcolor="#ffffff"><pre>
  995. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  996. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  997. ]&gt;
  998. </pre></td>
  999. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1000. </tr>
  1001. <tr>
  1002. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1003. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1004. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1005. </tr>
  1006. </table>
  1007. </div>
  1008. </blockquote>
  1009. </td></tr>
  1010. </table>
  1011. </a>
  1012. <a name="mail-logger">
  1013. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1014. <tr><td bgcolor="#828DA6">
  1015. <font color="#ffffff" face="arial,helvetica,sanserif">
  1016. <strong>
  1017. How do I send an email with the result of my build
  1018. process?
  1019. </strong>
  1020. </font>
  1021. </td></tr>
  1022. <tr><td>
  1023. <blockquote>
  1024. <p>You can use a custom BuildListener, that sends out an email
  1025. in the buildFinished() method. Will Glozer
  1026. &lt;will.glozer@jda.com&gt; has written such a listener based
  1027. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>,
  1028. the source is</p>
  1029. <div align="left">
  1030. <table cellspacing="4" cellpadding="0" border="0">
  1031. <tr>
  1032. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1033. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1034. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1035. </tr>
  1036. <tr>
  1037. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1038. <td bgcolor="#ffffff"><pre>
  1039. import java.io.*;
  1040. import java.util.*;
  1041. import javax.mail.*;
  1042. import javax.mail.internet.*;
  1043. import org.apache.tools.ant.*;
  1044. /**
  1045. * A simple listener that waits for a build to finish and sends an email
  1046. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1047. * are fairly self explanatory.
  1048. *
  1049. * @author Will Glozer
  1050. * @version 1.05a 09/06/2000
  1051. */
  1052. public class BuildMonitor implements BuildListener {
  1053. protected Properties props;
  1054. /**
  1055. * Create a new BuildMonitor.
  1056. */
  1057. public BuildMonitor() throws Exception {
  1058. props = new Properties();
  1059. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1060. props.load(is);
  1061. is.close();
  1062. }
  1063. public void buildStarted(BuildEvent e) {
  1064. }
  1065. /**
  1066. * Determine the status of the build and the actions to follow, now that
  1067. * the build has completed.
  1068. *
  1069. * @param e Event describing the build tatus.
  1070. */
  1071. public void buildFinished(BuildEvent e) {
  1072. Throwable th = e.getException();
  1073. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1074. try {
  1075. String key = &quot;build.&quot; + status;
  1076. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1077. return;
  1078. }
  1079. Session session = Session.getDefaultInstance(props, null);
  1080. MimeMessage message = new MimeMessage(session);
  1081. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1082. props.getProperty(key + &quot;.email.to&quot;)));
  1083. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1084. BufferedReader br = new BufferedReader(new FileReader(
  1085. props.getProperty(&quot;build.log&quot;)));
  1086. StringWriter sw = new StringWriter();
  1087. String line = br.readLine();
  1088. while (line != null) {
  1089. sw.write(line);
  1090. sw.write(&quot;\n&quot;);
  1091. line = br.readLine();
  1092. }
  1093. br.close();
  1094. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1095. sw.close();
  1096. Transport transport = session.getTransport();
  1097. transport.connect();
  1098. transport.send(message);
  1099. transport.close();
  1100. } catch (Exception ex) {
  1101. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1102. ex.printStackTrace();
  1103. }
  1104. }
  1105. /**
  1106. * Parse a comma separated list of internet email addresses.
  1107. *
  1108. * @param s The list of addresses.
  1109. * @return Array of Addresses.
  1110. */
  1111. protected Address[] parseAddresses(String s) throws Exception {
  1112. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1113. Address[] addrs = new Address[st.countTokens()];
  1114. for (int i = 0; i &lt; addrs.length; i++) {
  1115. addrs[i] = new InternetAddress(st.nextToken());
  1116. }
  1117. return addrs;
  1118. }
  1119. public void messageLogged(BuildEvent e) {
  1120. }
  1121. public void targetStarted(BuildEvent e) {
  1122. }
  1123. public void targetFinished(BuildEvent e) {
  1124. }
  1125. public void taskStarted(BuildEvent e) {
  1126. }
  1127. public void taskFinished(BuildEvent e) {
  1128. }
  1129. }
  1130. </pre></td>
  1131. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1132. </tr>
  1133. <tr>
  1134. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1135. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1136. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1137. </tr>
  1138. </table>
  1139. </div>
  1140. <p>With a <code>monitor.properties</code> like this</p>
  1141. <div align="left">
  1142. <table cellspacing="4" cellpadding="0" border="0">
  1143. <tr>
  1144. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1145. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1146. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1147. </tr>
  1148. <tr>
  1149. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1150. <td bgcolor="#ffffff"><pre>
  1151. # configuration for build monitor
  1152. mail.transport.protocol=smtp
  1153. mail.smtp.host=&lt;host&gt;
  1154. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1155. build.log=build.log
  1156. build.failed.notify=true
  1157. build.failed.email.to=will.glozer@jda.com
  1158. build.failed.email.subject=Nightly build failed!
  1159. build.succeeded.notify=true
  1160. build.succeeded.email.to=will.glozer@jda.com
  1161. build.succeeded.email.subject=Nightly build succeeded!
  1162. </pre></td>
  1163. <td bgcolor="#023264" width="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" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1167. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1168. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1169. </tr>
  1170. </table>
  1171. </div>
  1172. <p><code>monitor.properties</code> should be placed right next
  1173. to your compiled <code>BuildMonitor.class</code>. To use it,
  1174. invoke Ant like</p>
  1175. <div align="left">
  1176. <table cellspacing="4" cellpadding="0" border="0">
  1177. <tr>
  1178. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1179. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1180. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1181. </tr>
  1182. <tr>
  1183. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1184. <td bgcolor="#ffffff"><pre>
  1185. ant -listener BuildMonitor
  1186. </pre></td>
  1187. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1188. </tr>
  1189. <tr>
  1190. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1191. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  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. </tr>
  1194. </table>
  1195. </div>
  1196. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1197. <code>activation.jar</code> from the
  1198. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1199. Beans Activation Framework</a> in your <code>CLASSPATH</code>.</p>
  1200. </blockquote>
  1201. </td></tr>
  1202. </table>
  1203. </a>
  1204. <a name="remove-cr">
  1205. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1206. <tr><td bgcolor="#828DA6">
  1207. <font color="#ffffff" face="arial,helvetica,sanserif">
  1208. <strong>
  1209. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  1210. 1.3 on Unix
  1211. </strong>
  1212. </font>
  1213. </td></tr>
  1214. <tr><td>
  1215. <blockquote>
  1216. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1217. has DOS instead of Unix line endings, you must remove the
  1218. carriage return characters from this file. This can be done by
  1219. using Ant's &lt;fixcrlf&gt; task or something like:</p>
  1220. <div align="left">
  1221. <table cellspacing="4" cellpadding="0" border="0">
  1222. <tr>
  1223. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1224. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1225. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1226. </tr>
  1227. <tr>
  1228. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1229. <td bgcolor="#ffffff"><pre>
  1230. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1231. mv /tmp/foo $ANT_HOME/bin/antRun
  1232. </pre></td>
  1233. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1234. </tr>
  1235. <tr>
  1236. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1237. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1238. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1239. </tr>
  1240. </table>
  1241. </div>
  1242. </blockquote>
  1243. </td></tr>
  1244. </table>
  1245. </a>
  1246. <a name="javadoc-cannot-execute">
  1247. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1248. <tr><td bgcolor="#828DA6">
  1249. <font color="#ffffff" face="arial,helvetica,sanserif">
  1250. <strong>
  1251. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1252. </strong>
  1253. </font>
  1254. </td></tr>
  1255. <tr><td>
  1256. <blockquote>
  1257. <p>There is a bug in the Solaris reference implementation of
  1258. 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>.
  1259. This also appears to be true under Linux, moving the JDK to
  1260. the front of the PATH fixes the problem.</p>
  1261. </blockquote>
  1262. </td></tr>
  1263. </table>
  1264. </a>
  1265. </blockquote>
  1266. </td></tr>
  1267. </table>
  1268. </td>
  1269. </tr>
  1270. <!-- FOOTER -->
  1271. <tr><td colspan="2">
  1272. <hr noshade="" size="1"/>
  1273. </td></tr>
  1274. <tr><td colspan="2">
  1275. <div align="center"><font color="#525D76" size="-1"><em>
  1276. Copyright &#169; 1999-2001, Apache Software Foundation
  1277. </em></font></div>
  1278. </td></tr>
  1279. </table>
  1280. </body>
  1281. </html>
  1282. <!-- end the processing -->