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

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