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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  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>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/">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. </ul>
  42. <p><strong>Download</strong></p>
  43. <ul>
  44. <li> <a href="http://jakarta.apache.org/site/binindex.html">Binaries</a>
  45. </li>
  46. <li> <a href="http://jakarta.apache.org/site/sourceindex.html">Source Code</a>
  47. </li>
  48. </ul>
  49. <p><strong>Jakarta</strong></p>
  50. <ul>
  51. <li> <a href="http://jakarta.apache.org/site/news.html">News & Status</a>
  52. </li>
  53. <li> <a href="http://jakarta.apache.org/site/mission.html">Mission</a>
  54. </li>
  55. <li> <a href="http://jakarta.apache.org/site/guidelines.html">Guidelines Notes</a>
  56. </li>
  57. <li> <a href="http://jakarta.apache.org/site/faqs.html">FAQs</a>
  58. </li>
  59. </ul>
  60. <p><strong>Get Involved</strong></p>
  61. <ul>
  62. <li> <a href="http://jakarta.apache.org/site/getinvolved.html">Overview</a>
  63. </li>
  64. <li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a>
  65. </li>
  66. <li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
  67. </li>
  68. <li> <a href="http://jakarta.apache.org/site/library.html">Reference Library</a>
  69. </li>
  70. <li> <a href="http://jakarta.apache.org/site/bugs.html">Bug Database</a>
  71. </li>
  72. </ul>
  73. </td>
  74. <td align="left" valign="top">
  75. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  76. <tr><td bgcolor="#525D76">
  77. <font color="#ffffff" face="arial,helvetica,sanserif">
  78. <strong>Questions</strong>
  79. </font>
  80. </td></tr>
  81. <tr><td>
  82. <blockquote>
  83. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  84. <tr><td bgcolor="#828DA6">
  85. <font color="#ffffff" face="arial,helvetica,sanserif">
  86. <strong>General</strong>
  87. </font>
  88. </td></tr>
  89. <tr><td>
  90. <blockquote>
  91. <ul>
  92. <li><a href="#what-is-ant">
  93. What is Ant?
  94. </a></li>
  95. <li><a href="#ant-name">
  96. Why do you call it Ant?
  97. </a></li>
  98. <li><a href="#history">
  99. Tell us a little bit about Ant's history.
  100. </a></li>
  101. </ul>
  102. </blockquote>
  103. </td></tr>
  104. </table>
  105. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  106. <tr><td bgcolor="#828DA6">
  107. <font color="#ffffff" face="arial,helvetica,sanserif">
  108. <strong>Installation</strong>
  109. </font>
  110. </td></tr>
  111. <tr><td>
  112. <blockquote>
  113. <ul>
  114. <li><a href="#no-gnu-tar">
  115. I get checksum errors when I try to extract the
  116. <code>tar.gz</code> distribution file. Why?
  117. </a></li>
  118. </ul>
  119. </blockquote>
  120. </td></tr>
  121. </table>
  122. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  123. <tr><td bgcolor="#828DA6">
  124. <font color="#ffffff" face="arial,helvetica,sanserif">
  125. <strong>Using Ant</strong>
  126. </font>
  127. </td></tr>
  128. <tr><td>
  129. <blockquote>
  130. <ul>
  131. <li><a href="#always-recompiles">
  132. Why does Ant always recompile all my Java files?
  133. </a></li>
  134. </ul>
  135. </blockquote>
  136. </td></tr>
  137. </table>
  138. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  139. <tr><td bgcolor="#828DA6">
  140. <font color="#ffffff" face="arial,helvetica,sanserif">
  141. <strong>Ant and IDEs/Editors</strong>
  142. </font>
  143. </td></tr>
  144. <tr><td>
  145. <blockquote>
  146. <ul>
  147. <li><a href="#integration">
  148. Is Ant supported by my IDE/Editor?
  149. </a></li>
  150. <li><a href="#emacs-mode">
  151. Why doesn't (X)Emacs parse the error messages generated
  152. by Ant correctly?
  153. </a></li>
  154. </ul>
  155. </blockquote>
  156. </td></tr>
  157. </table>
  158. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  159. <tr><td bgcolor="#828DA6">
  160. <font color="#ffffff" face="arial,helvetica,sanserif">
  161. <strong>Advanced issues</strong>
  162. </font>
  163. </td></tr>
  164. <tr><td>
  165. <blockquote>
  166. <ul>
  167. <li><a href="#dtd">
  168. Is there a DTD that I can use to validate my build
  169. files?
  170. </a></li>
  171. <li><a href="#xml-entity-include">
  172. How do I include an XML snippet in my build file?
  173. </a></li>
  174. <li><a href="#mail-logger">
  175. How do I send an email with the result of my build
  176. process?
  177. </a></li>
  178. </ul>
  179. </blockquote>
  180. </td></tr>
  181. </table>
  182. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  183. <tr><td bgcolor="#828DA6">
  184. <font color="#ffffff" face="arial,helvetica,sanserif">
  185. <strong>Known problems</strong>
  186. </font>
  187. </td></tr>
  188. <tr><td>
  189. <blockquote>
  190. <ul>
  191. <li><a href="#remove-cr">
  192. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  193. 1.3 on Unix
  194. </a></li>
  195. <li><a href="#javadoc-cannot-execute">
  196. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  197. </a></li>
  198. </ul>
  199. </blockquote>
  200. </td></tr>
  201. </table>
  202. </blockquote>
  203. </td></tr>
  204. </table>
  205. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  206. <tr><td bgcolor="#525D76">
  207. <font color="#ffffff" face="arial,helvetica,sanserif">
  208. <strong>Answers</strong>
  209. </font>
  210. </td></tr>
  211. <tr><td>
  212. <blockquote>
  213. <a name="what-is-ant">
  214. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  215. <tr><td bgcolor="#828DA6">
  216. <font color="#ffffff" face="arial,helvetica,sanserif">
  217. <strong>
  218. What is Ant?
  219. </strong>
  220. </font>
  221. </td></tr>
  222. <tr><td>
  223. <blockquote>
  224. <p> Ant is a Java based build tool. In theory it is kind of
  225. like "make" without makes wrinkles and with the full
  226. portability of pure Java code.</p>
  227. </blockquote>
  228. </td></tr>
  229. </table>
  230. </a>
  231. <a name="ant-name">
  232. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  233. <tr><td bgcolor="#828DA6">
  234. <font color="#ffffff" face="arial,helvetica,sanserif">
  235. <strong>
  236. Why do you call it Ant?
  237. </strong>
  238. </font>
  239. </td></tr>
  240. <tr><td>
  241. <blockquote>
  242. <p>According to Ant's original author James Duncan
  243. Davidson, the name is an acronym for "Another Neat
  244. Tool".</p>
  245. <p>Later explanations go along the lines of "Ants are
  246. doing an extremely good job at building things" or
  247. "Ants are very small and can carry a weight a dozen times
  248. of their own" - describing what Ant is intended to
  249. be.</p>
  250. </blockquote>
  251. </td></tr>
  252. </table>
  253. </a>
  254. <a name="history">
  255. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  256. <tr><td bgcolor="#828DA6">
  257. <font color="#ffffff" face="arial,helvetica,sanserif">
  258. <strong>
  259. Tell us a little bit about Ant's history.
  260. </strong>
  261. </font>
  262. </td></tr>
  263. <tr><td>
  264. <blockquote>
  265. <p>Initially Ant was part of the Tomcat code base when it was
  266. donated to the Apache Software Foundation - it has been
  267. created by James Duncan Davidson, who also is the original
  268. author of Tomcat. Ant was there to build Tomcat, nothing
  269. else.</p>
  270. <p>Soon thereafter several open source Java projects realized
  271. that Ant could solve the problems they had with makefiles.
  272. Starting with the projects hosted at Jakarta and the old Java
  273. Apache project, Ant spread like a virus and now is the build
  274. tool of choice for a lot of projects.</p>
  275. <p>In January 2000 Ant was moved to a separate CVS module and
  276. was promoted to a project of its own, independent of
  277. Tomcat.</p>
  278. <p>The first version of Ant that was exposed a lager audience
  279. was the one that shipped with Tomcat's 3.1 release on 19 April
  280. 2000. This version has later been referenced to as Ant
  281. 0.3.1.</p>
  282. <p>The first official release of Ant as a stand alone product was
  283. Ant 1.1 released on 19 July 2000. The complete release
  284. history:</p>
  285. <table>
  286. <tr>
  287. <td bgcolor="#039acc" colspan="" rowspan=""
  288. valign="top" align="left">
  289. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  290. Ant Version
  291. </font>
  292. </td>
  293. <td bgcolor="#039acc" colspan="" rowspan=""
  294. valign="top" align="left">
  295. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  296. Release Date
  297. </font>
  298. </td>
  299. </tr>
  300. <tr>
  301. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  302. valign="top" align="left">
  303. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  304. 1.1
  305. </font>
  306. </td>
  307. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  308. valign="top" align="left">
  309. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  310. 19 July 2000
  311. </font>
  312. </td>
  313. </tr>
  314. <tr>
  315. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  316. valign="top" align="left">
  317. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  318. 1.2
  319. </font>
  320. </td>
  321. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  322. valign="top" align="left">
  323. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  324. 24 October 2000
  325. </font>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  330. valign="top" align="left">
  331. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  332. 1.3
  333. </font>
  334. </td>
  335. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  336. valign="top" align="left">
  337. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  338. 3 March 2001
  339. </font>
  340. </td>
  341. </tr>
  342. </table>
  343. </blockquote>
  344. </td></tr>
  345. </table>
  346. </a>
  347. <a name="no-gnu-tar">
  348. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  349. <tr><td bgcolor="#828DA6">
  350. <font color="#ffffff" face="arial,helvetica,sanserif">
  351. <strong>
  352. I get checksum errors when I try to extract the
  353. <code>tar.gz</code> distribution file. Why?
  354. </strong>
  355. </font>
  356. </td></tr>
  357. <tr><td>
  358. <blockquote>
  359. <p>Ant's distribution contains file names that are longer
  360. than 100 characters, which is not supported by the standard
  361. tar file format. Several different implementations of tar use
  362. different and incompatible ways to work around this
  363. restriction.</p>
  364. <p>Ant's &lt;tar&gt; task can create tar archives that use
  365. the GNU tar extension, and this has been used when putting
  366. together the distribution. If you are using a different
  367. version of tar (for example, the one shipping with Solaris),
  368. you cannot use it to extract the archive.</p>
  369. <p>The solution is to either install GNU tar, which can be
  370. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
  371. or use the zip archive instead (you can extract it using
  372. <code>jar xf</code>).</p>
  373. </blockquote>
  374. </td></tr>
  375. </table>
  376. </a>
  377. <a name="always-recompiles">
  378. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  379. <tr><td bgcolor="#828DA6">
  380. <font color="#ffffff" face="arial,helvetica,sanserif">
  381. <strong>
  382. Why does Ant always recompile all my Java files?
  383. </strong>
  384. </font>
  385. </td></tr>
  386. <tr><td>
  387. <blockquote>
  388. <p>In order to find out which files should be compiled, Ant
  389. compares the timestamps of the source files to those of the
  390. resulting <code>.class</code> files. Opening all source files
  391. to find out which package they belong to would be very
  392. inefficient - instead of this, Ant expects you to place your
  393. source files in a directory hierarchy that mirrors your
  394. package hierarchy and to point Ant to the root of this
  395. directory tree with the <code>srcdir</code> attribute.</p>
  396. <p>Say you have <code>&lt;javac srcdir="src"
  397. destdir="dest" /&gt;</code>. If Ant finds a file
  398. <code>src/a/b/C.java</code> it expects it to be in package
  399. <code>a.b</code> so that the resulting <code>.class</code>
  400. file is going to be <code>dest/a/b/C.class</code>.</p>
  401. <p>If your setup is different, Ant's heuristic won't work and
  402. it will recompile classes that are up to date. Ant is not the
  403. only tool, that expects a source tree layout like this.</p>
  404. </blockquote>
  405. </td></tr>
  406. </table>
  407. </a>
  408. <a name="integration">
  409. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  410. <tr><td bgcolor="#828DA6">
  411. <font color="#ffffff" face="arial,helvetica,sanserif">
  412. <strong>
  413. Is Ant supported by my IDE/Editor?
  414. </strong>
  415. </font>
  416. </td></tr>
  417. <tr><td>
  418. <blockquote>
  419. <p>See the <a href="external.html#IDE%47Editor+Integration">section
  420. on IDE integration</a> on our external tools page.</p>
  421. </blockquote>
  422. </td></tr>
  423. </table>
  424. </a>
  425. <a name="emacs-mode">
  426. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  427. <tr><td bgcolor="#828DA6">
  428. <font color="#ffffff" face="arial,helvetica,sanserif">
  429. <strong>
  430. Why doesn't (X)Emacs parse the error messages generated
  431. by Ant correctly?
  432. </strong>
  433. </font>
  434. </td></tr>
  435. <tr><td>
  436. <blockquote>
  437. <p>Ant adds a "banner" with the name of the current
  438. task in front of all messages - and there are no built-in
  439. regular expressions in Emacs that would account for this.</p>
  440. <p>You can disable this banner by invoking Ant with the
  441. <code>-emacs</code> switch. Alternatively you can add the
  442. following snippet to your <code>.emacs</code> to make Emacs
  443. understand Ant's output.</p>
  444. <div align="left">
  445. <table cellspacing="4" cellpadding="0" border="0">
  446. <tr>
  447. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  448. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  449. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  450. </tr>
  451. <tr>
  452. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  453. <td bgcolor="#ffffff"><pre>
  454. (require 'compile)
  455. (setq compilation-error-regexp-alist
  456. (append (list
  457. ;; works for jikes
  458. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  459. ;; works for javac
  460. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  461. compilation-error-regexp-alist))
  462. </pre></td>
  463. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  464. </tr>
  465. <tr>
  466. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  467. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  468. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  469. </tr>
  470. </table>
  471. </div>
  472. </blockquote>
  473. </td></tr>
  474. </table>
  475. </a>
  476. <a name="dtd">
  477. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  478. <tr><td bgcolor="#828DA6">
  479. <font color="#ffffff" face="arial,helvetica,sanserif">
  480. <strong>
  481. Is there a DTD that I can use to validate my build
  482. files?
  483. </strong>
  484. </font>
  485. </td></tr>
  486. <tr><td>
  487. <blockquote>
  488. <p>An incomplete DTD can be created by the
  489. <code>&lt;antstructure&gt;</code> task - but this one
  490. has a few problems:</p>
  491. <ul>
  492. <li>It doesn't know about required attributes. Only
  493. manual tweaking of this file can help here.</li>
  494. <li>It is not complete - if you add new tasks via
  495. <code>&lt;taskdef&gt;</code> it won't know about it. See
  496. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  497. page</a> by Michel Casabianca for a solution to this
  498. problem. Note that the DTD you can download at this page
  499. is based on Ant 0.3.1.</li>
  500. <li>It may even be an invalid DTD. As Ant allows tasks
  501. writers to define arbitrary elements, name collisions will
  502. happen quite frequently - if your version of Ant contains
  503. the optional <code>&lt;test&gt;</code> and
  504. <code>&lt;junit&gt;</code> tasks, there are two XML
  505. elements named test (the task and the nested child element
  506. of <code>&lt;junit&gt;</code>) with different attribute
  507. lists. This problem cannot be solved, DTDs don't give a
  508. syntax rich enough to support this.</li>
  509. </ul>
  510. </blockquote>
  511. </td></tr>
  512. </table>
  513. </a>
  514. <a name="xml-entity-include">
  515. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  516. <tr><td bgcolor="#828DA6">
  517. <font color="#ffffff" face="arial,helvetica,sanserif">
  518. <strong>
  519. How do I include an XML snippet in my build file?
  520. </strong>
  521. </font>
  522. </td></tr>
  523. <tr><td>
  524. <blockquote>
  525. <p>You can use XML's way of including external files and let
  526. the parser do the job for Ant:</p>
  527. <div align="left">
  528. <table cellspacing="4" cellpadding="0" border="0">
  529. <tr>
  530. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  531. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  532. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  533. </tr>
  534. <tr>
  535. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  536. <td bgcolor="#ffffff"><pre>
  537. &lt;?xml version=&quot;1.0&quot;?&gt;
  538. &lt;!DOCTYPE project [
  539. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  540. ]&gt;
  541. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  542. &lt;target name=&quot;setup&quot;&gt;
  543. ...
  544. &lt;/target&gt;
  545. &amp;common;
  546. ...
  547. &lt;/project&gt;
  548. </pre></td>
  549. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  550. </tr>
  551. <tr>
  552. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  553. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  554. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  555. </tr>
  556. </table>
  557. </div>
  558. <p>will literally include the contents of <code>common.xml</code> where
  559. you've placed the <code>&amp;common;</code> entity.</p>
  560. <p>In combination with a DTD, this would look like this:</p>
  561. <div align="left">
  562. <table cellspacing="4" cellpadding="0" border="0">
  563. <tr>
  564. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  565. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  566. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  567. </tr>
  568. <tr>
  569. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  570. <td bgcolor="#ffffff"><pre>
  571. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  572. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  573. ]&gt;
  574. </pre></td>
  575. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  576. </tr>
  577. <tr>
  578. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  579. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  580. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  581. </tr>
  582. </table>
  583. </div>
  584. </blockquote>
  585. </td></tr>
  586. </table>
  587. </a>
  588. <a name="mail-logger">
  589. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  590. <tr><td bgcolor="#828DA6">
  591. <font color="#ffffff" face="arial,helvetica,sanserif">
  592. <strong>
  593. How do I send an email with the result of my build
  594. process?
  595. </strong>
  596. </font>
  597. </td></tr>
  598. <tr><td>
  599. <blockquote>
  600. <p>You can use a custom BuildListener, that sends out an email
  601. in the buildFinished() method. Will Glozer
  602. &lt;will.glozer@jda.com&gt; has written such a listener based
  603. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>,
  604. the source is</p>
  605. <div align="left">
  606. <table cellspacing="4" cellpadding="0" border="0">
  607. <tr>
  608. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  609. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  610. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  611. </tr>
  612. <tr>
  613. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  614. <td bgcolor="#ffffff"><pre>
  615. import java.io.*;
  616. import java.util.*;
  617. import javax.mail.*;
  618. import javax.mail.internet.*;
  619. import org.apache.tools.ant.*;
  620. /**
  621. * A simple listener that waits for a build to finish and sends an email
  622. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  623. * are fairly self explanatory.
  624. *
  625. * @author Will Glozer
  626. * @version 1.05a 09/06/2000
  627. */
  628. public class BuildMonitor implements BuildListener {
  629. protected Properties props;
  630. /**
  631. * Create a new BuildMonitor.
  632. */
  633. public BuildMonitor() throws Exception {
  634. props = new Properties();
  635. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  636. props.load(is);
  637. is.close();
  638. }
  639. public void buildStarted(BuildEvent e) {
  640. }
  641. /**
  642. * Determine the status of the build and the actions to follow, now that
  643. * the build has completed.
  644. *
  645. * @param e Event describing the build tatus.
  646. */
  647. public void buildFinished(BuildEvent e) {
  648. Throwable th = e.getException();
  649. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  650. try {
  651. String key = &quot;build.&quot; + status;
  652. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  653. return;
  654. }
  655. Session session = Session.getDefaultInstance(props, null);
  656. MimeMessage message = new MimeMessage(session);
  657. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  658. props.getProperty(key + &quot;.email.to&quot;)));
  659. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  660. BufferedReader br = new BufferedReader(new FileReader(
  661. props.getProperty(&quot;build.log&quot;)));
  662. StringWriter sw = new StringWriter();
  663. String line = br.readLine();
  664. while (line != null) {
  665. sw.write(line);
  666. sw.write(&quot;\n&quot;);
  667. line = br.readLine();
  668. }
  669. br.close();
  670. message.setText(sw.toString(), &quot;UTF-8&quot;);
  671. sw.close();
  672. Transport transport = session.getTransport();
  673. transport.connect();
  674. transport.send(message);
  675. transport.close();
  676. } catch (Exception ex) {
  677. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  678. ex.printStackTrace();
  679. }
  680. }
  681. /**
  682. * Parse a comma separated list of internet email addresses.
  683. *
  684. * @param s The list of addresses.
  685. * @return Array of Addresses.
  686. */
  687. protected Address[] parseAddresses(String s) throws Exception {
  688. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  689. Address[] addrs = new Address[st.countTokens()];
  690. for (int i = 0; i &lt; addrs.length; i++) {
  691. addrs[i] = new InternetAddress(st.nextToken());
  692. }
  693. return addrs;
  694. }
  695. public void messageLogged(BuildEvent e) {
  696. }
  697. public void targetStarted(BuildEvent e) {
  698. }
  699. public void targetFinished(BuildEvent e) {
  700. }
  701. public void taskStarted(BuildEvent e) {
  702. }
  703. public void taskFinished(BuildEvent e) {
  704. }
  705. }
  706. </pre></td>
  707. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  708. </tr>
  709. <tr>
  710. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  711. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  712. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  713. </tr>
  714. </table>
  715. </div>
  716. <p>With a <code>monitor.properties</code> like this</p>
  717. <div align="left">
  718. <table cellspacing="4" cellpadding="0" border="0">
  719. <tr>
  720. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  721. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  722. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  723. </tr>
  724. <tr>
  725. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  726. <td bgcolor="#ffffff"><pre>
  727. # configuration for build monitor
  728. mail.transport.protocol=smtp
  729. mail.smtp.host=&lt;host&gt;
  730. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  731. build.log=build.log
  732. build.failed.notify=true
  733. build.failed.email.to=will.glozer@jda.com
  734. build.failed.email.subject=Nightly build failed!
  735. build.succeeded.notify=true
  736. build.succeeded.email.to=will.glozer@jda.com
  737. build.succeeded.email.subject=Nightly build succeeded!
  738. </pre></td>
  739. <td bgcolor="#023264" width="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" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  743. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  744. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  745. </tr>
  746. </table>
  747. </div>
  748. <p><code>monitor.properties</code> should be placed right next
  749. to your compiled <code>BuildMonitor.class</code>. To use it,
  750. invoke Ant like</p>
  751. <div align="left">
  752. <table cellspacing="4" cellpadding="0" border="0">
  753. <tr>
  754. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  755. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  756. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  757. </tr>
  758. <tr>
  759. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  760. <td bgcolor="#ffffff"><pre>
  761. ant -listener BuildMonitor
  762. </pre></td>
  763. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  764. </tr>
  765. <tr>
  766. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  767. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  768. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  769. </tr>
  770. </table>
  771. </div>
  772. <p>Make sure that <code>mail.jar</code> from JavaMail and
  773. <code>activation.jar</code> from the
  774. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  775. Beans Activation Framework</a> in your <code>CLASSPATH</code>.</p>
  776. </blockquote>
  777. </td></tr>
  778. </table>
  779. </a>
  780. <a name="remove-cr">
  781. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  782. <tr><td bgcolor="#828DA6">
  783. <font color="#ffffff" face="arial,helvetica,sanserif">
  784. <strong>
  785. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  786. 1.3 on Unix
  787. </strong>
  788. </font>
  789. </td></tr>
  790. <tr><td>
  791. <blockquote>
  792. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  793. has DOS instead of Unix line endings, you must remove the
  794. carriage return characters from this file. This can be done by
  795. using Ant's &lt;fixcrlf&gt; task or something like:</p>
  796. <div align="left">
  797. <table cellspacing="4" cellpadding="0" border="0">
  798. <tr>
  799. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  800. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  801. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  802. </tr>
  803. <tr>
  804. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  805. <td bgcolor="#ffffff"><pre>
  806. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  807. mv /tmp/foo $ANT_HOME/bin/antRun
  808. </pre></td>
  809. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  810. </tr>
  811. <tr>
  812. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  813. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  814. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  815. </tr>
  816. </table>
  817. </div>
  818. </blockquote>
  819. </td></tr>
  820. </table>
  821. </a>
  822. <a name="javadoc-cannot-execute">
  823. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  824. <tr><td bgcolor="#828DA6">
  825. <font color="#ffffff" face="arial,helvetica,sanserif">
  826. <strong>
  827. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  828. </strong>
  829. </font>
  830. </td></tr>
  831. <tr><td>
  832. <blockquote>
  833. <p>There is a bug in the Solaris reference implementation of
  834. 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>.
  835. This also appears to be true under Linux, moving the JDK to
  836. the front of the PATH fixes the problem.</p>
  837. </blockquote>
  838. </td></tr>
  839. </table>
  840. </a>
  841. </blockquote>
  842. </td></tr>
  843. </table>
  844. </td>
  845. </tr>
  846. <!-- FOOTER -->
  847. <tr><td colspan="2">
  848. <hr noshade="" size="1"/>
  849. </td></tr>
  850. <tr><td colspan="2">
  851. <div align="center"><font color="#525D76" size="-1"><em>
  852. Copyright &#169; 1999-2001, Apache Software Foundation
  853. </em></font></div>
  854. </td></tr>
  855. </table>
  856. </body>
  857. </html>
  858. <!-- end the processing -->