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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  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>Ant and IDEs/Editors</strong>
  126. </font>
  127. </td></tr>
  128. <tr><td>
  129. <blockquote>
  130. <ul>
  131. <li><a href="#integration">
  132. Is Ant supported by my IDE/Editor?
  133. </a></li>
  134. <li><a href="#emacs-mode">
  135. Why doesn't (X)Emacs parse the error messages generated
  136. by Ant correctly?
  137. </a></li>
  138. </ul>
  139. </blockquote>
  140. </td></tr>
  141. </table>
  142. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  143. <tr><td bgcolor="#828DA6">
  144. <font color="#ffffff" face="arial,helvetica,sanserif">
  145. <strong>Advanced issues</strong>
  146. </font>
  147. </td></tr>
  148. <tr><td>
  149. <blockquote>
  150. <ul>
  151. <li><a href="#xml-entity-include">
  152. How do I include an XML snippet in my build file?
  153. </a></li>
  154. <li><a href="#mail-logger">
  155. How do I send an email with the result of my build
  156. process?
  157. </a></li>
  158. </ul>
  159. </blockquote>
  160. </td></tr>
  161. </table>
  162. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  163. <tr><td bgcolor="#828DA6">
  164. <font color="#ffffff" face="arial,helvetica,sanserif">
  165. <strong>Known problems</strong>
  166. </font>
  167. </td></tr>
  168. <tr><td>
  169. <blockquote>
  170. <ul>
  171. <li><a href="#remove-cr">
  172. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  173. 1.3 on Unix
  174. </a></li>
  175. <li><a href="#javadoc-cannot-execute">
  176. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  177. </a></li>
  178. </ul>
  179. </blockquote>
  180. </td></tr>
  181. </table>
  182. </blockquote>
  183. </td></tr>
  184. </table>
  185. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  186. <tr><td bgcolor="#525D76">
  187. <font color="#ffffff" face="arial,helvetica,sanserif">
  188. <strong>Answers</strong>
  189. </font>
  190. </td></tr>
  191. <tr><td>
  192. <blockquote>
  193. <a name="what-is-ant">
  194. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  195. <tr><td bgcolor="#828DA6">
  196. <font color="#ffffff" face="arial,helvetica,sanserif">
  197. <strong>
  198. What is Ant?
  199. </strong>
  200. </font>
  201. </td></tr>
  202. <tr><td>
  203. <blockquote>
  204. <p> Ant is a Java based build tool. In theory it is kind of
  205. like "make" without makes wrinkles and with the full
  206. portability of pure Java code.</p>
  207. </blockquote>
  208. </td></tr>
  209. </table>
  210. </a>
  211. <a name="ant-name">
  212. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  213. <tr><td bgcolor="#828DA6">
  214. <font color="#ffffff" face="arial,helvetica,sanserif">
  215. <strong>
  216. Why do you call it Ant?
  217. </strong>
  218. </font>
  219. </td></tr>
  220. <tr><td>
  221. <blockquote>
  222. <p>According to Ant's original author James Duncan
  223. Davidson, the name is an acronym for "Another Neat
  224. Tool".</p>
  225. <p>Later explanations go along the lines of "Ants are
  226. doing an extremely good job at building things" or
  227. "Ants are very small and can carry a weight a dozen times
  228. of their own" - describing what Ant is intended to
  229. be.</p>
  230. </blockquote>
  231. </td></tr>
  232. </table>
  233. </a>
  234. <a name="history">
  235. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  236. <tr><td bgcolor="#828DA6">
  237. <font color="#ffffff" face="arial,helvetica,sanserif">
  238. <strong>
  239. Tell us a little bit about Ant's history.
  240. </strong>
  241. </font>
  242. </td></tr>
  243. <tr><td>
  244. <blockquote>
  245. <p>Initially Ant was part of the Tomcat code base when it was
  246. donated to the Apache Software Foundation - it has been
  247. created by James Duncan Davidson, who also is the original
  248. author of Tomcat. Ant was there to build Tomcat, nothing
  249. else.</p>
  250. <p>Soon thereafter several open source Java projects realized
  251. that Ant could solve the problems they had with makefiles.
  252. Starting with the projects hosted at Jakarta and the old Java
  253. Apache project, Ant spread like a virus and now is the build
  254. tool of choice for a lot of projects.</p>
  255. <p>In January 2000 Ant was moved to a separate CVS module and
  256. was promoted to a project of its own, independent of
  257. Tomcat.</p>
  258. <p>The first version of Ant that was exposed a lager audience
  259. was the one that shipped with Tomcat's 3.1 release on 19 April
  260. 2000. This version has later been referenced to as Ant
  261. 0.3.1.</p>
  262. <p>The first official release of Ant as a stand alone product was
  263. Ant 1.1 released on 19 July 2000. The complete release
  264. history:</p>
  265. <table>
  266. <tr>
  267. <td bgcolor="#039acc" colspan="" rowspan=""
  268. valign="top" align="left">
  269. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  270. Ant Version
  271. </font>
  272. </td>
  273. <td bgcolor="#039acc" colspan="" rowspan=""
  274. valign="top" align="left">
  275. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  276. Release Date
  277. </font>
  278. </td>
  279. </tr>
  280. <tr>
  281. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  282. valign="top" align="left">
  283. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  284. 1.1
  285. </font>
  286. </td>
  287. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  288. valign="top" align="left">
  289. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  290. 19 July 2000
  291. </font>
  292. </td>
  293. </tr>
  294. <tr>
  295. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  296. valign="top" align="left">
  297. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  298. 1.2
  299. </font>
  300. </td>
  301. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  302. valign="top" align="left">
  303. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  304. 24 October 2000
  305. </font>
  306. </td>
  307. </tr>
  308. <tr>
  309. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  310. valign="top" align="left">
  311. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  312. 1.3
  313. </font>
  314. </td>
  315. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  316. valign="top" align="left">
  317. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  318. 3 March 2001
  319. </font>
  320. </td>
  321. </tr>
  322. </table>
  323. </blockquote>
  324. </td></tr>
  325. </table>
  326. </a>
  327. <a name="no-gnu-tar">
  328. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  329. <tr><td bgcolor="#828DA6">
  330. <font color="#ffffff" face="arial,helvetica,sanserif">
  331. <strong>
  332. I get checksum errors when I try to extract the
  333. <code>tar.gz</code> distribution file. Why?
  334. </strong>
  335. </font>
  336. </td></tr>
  337. <tr><td>
  338. <blockquote>
  339. <p>Ant's distribution contains file names that are longer
  340. than 100 characters, which is not supported by the standard
  341. tar file format. Several different implementations of tar use
  342. different and incompatible ways to work around this
  343. restriction.</p>
  344. <p>Ant's &lt;tar&gt; task can create tar archives that use
  345. the GNU tar extension, and this has been used when putting
  346. together the distribution. If you are using a different
  347. version of tar (for example, the one shipping with Solaris),
  348. you cannot use it to extract the archive.</p>
  349. <p>The solution is to either install GNU tar, which can be
  350. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
  351. or use the zip archive instead (you can extract it using
  352. <code>jar xf</code>).</p>
  353. </blockquote>
  354. </td></tr>
  355. </table>
  356. </a>
  357. <a name="integration">
  358. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  359. <tr><td bgcolor="#828DA6">
  360. <font color="#ffffff" face="arial,helvetica,sanserif">
  361. <strong>
  362. Is Ant supported by my IDE/Editor?
  363. </strong>
  364. </font>
  365. </td></tr>
  366. <tr><td>
  367. <blockquote>
  368. <p>See the <a href="external.html#IDE%47Editor+Integration">section
  369. on IDE integration</a> on our external tools page.</p>
  370. </blockquote>
  371. </td></tr>
  372. </table>
  373. </a>
  374. <a name="emacs-mode">
  375. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  376. <tr><td bgcolor="#828DA6">
  377. <font color="#ffffff" face="arial,helvetica,sanserif">
  378. <strong>
  379. Why doesn't (X)Emacs parse the error messages generated
  380. by Ant correctly?
  381. </strong>
  382. </font>
  383. </td></tr>
  384. <tr><td>
  385. <blockquote>
  386. <p>Ant adds a "banner" with the name of the current
  387. task in front of all messages - and there are no built-in
  388. regular expressions in Emacs that would account for this.</p>
  389. <p>You can disable this banner by invoking Ant with the
  390. <code>-emacs</code> switch. Alternatively you can add the
  391. following snippet to your <code>.emacs</code> to make Emacs
  392. understand Ant's output.</p>
  393. <div align="left">
  394. <table cellspacing="4" cellpadding="0" border="0">
  395. <tr>
  396. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  397. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  398. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  399. </tr>
  400. <tr>
  401. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  402. <td bgcolor="#ffffff"><pre>
  403. (require 'compile)
  404. (setq compilation-error-regexp-alist
  405. (append (list
  406. ;; works for jikes
  407. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  408. ;; works for javac
  409. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  410. compilation-error-regexp-alist))
  411. </pre></td>
  412. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  413. </tr>
  414. <tr>
  415. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  416. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  417. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  418. </tr>
  419. </table>
  420. </div>
  421. </blockquote>
  422. </td></tr>
  423. </table>
  424. </a>
  425. <a name="xml-entity-include">
  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. How do I include an XML snippet in my build file?
  431. </strong>
  432. </font>
  433. </td></tr>
  434. <tr><td>
  435. <blockquote>
  436. <p>You can use XML's way of including external files and let
  437. the parser do the job for Ant:</p>
  438. <div align="left">
  439. <table cellspacing="4" cellpadding="0" border="0">
  440. <tr>
  441. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  442. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  443. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  444. </tr>
  445. <tr>
  446. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  447. <td bgcolor="#ffffff"><pre>
  448. &lt;?xml version=&quot;1.0&quot;?&gt;
  449. &lt;!DOCTYPE project [
  450. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  451. ]&gt;
  452. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  453. &lt;target name=&quot;setup&quot;&gt;
  454. ...
  455. &lt;/target&gt;
  456. &amp;common;
  457. ...
  458. &lt;/project&gt;
  459. </pre></td>
  460. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  461. </tr>
  462. <tr>
  463. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  464. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  465. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  466. </tr>
  467. </table>
  468. </div>
  469. <p>will literally include the contents of <code>common.xml</code> where
  470. you've placed the <code>&amp;common;</code> entity.</p>
  471. <p>In combination with a DTD, this would look like this:</p>
  472. <div align="left">
  473. <table cellspacing="4" cellpadding="0" border="0">
  474. <tr>
  475. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  476. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  477. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  478. </tr>
  479. <tr>
  480. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  481. <td bgcolor="#ffffff"><pre>
  482. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  483. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  484. ]&gt;
  485. </pre></td>
  486. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  487. </tr>
  488. <tr>
  489. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  490. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  491. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  492. </tr>
  493. </table>
  494. </div>
  495. </blockquote>
  496. </td></tr>
  497. </table>
  498. </a>
  499. <a name="mail-logger">
  500. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  501. <tr><td bgcolor="#828DA6">
  502. <font color="#ffffff" face="arial,helvetica,sanserif">
  503. <strong>
  504. How do I send an email with the result of my build
  505. process?
  506. </strong>
  507. </font>
  508. </td></tr>
  509. <tr><td>
  510. <blockquote>
  511. <p>You can use a custom BuildListener, that sends out an email
  512. in the buildFinished() method. Will Glozer
  513. &lt;will.glozer@jda.com&gt; has written such a listener based
  514. on JavaMail, the source is</p>
  515. <div align="left">
  516. <table cellspacing="4" cellpadding="0" border="0">
  517. <tr>
  518. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  519. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  520. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  521. </tr>
  522. <tr>
  523. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  524. <td bgcolor="#ffffff"><pre>
  525. import java.io.*;
  526. import java.util.*;
  527. import javax.mail.*;
  528. import javax.mail.internet.*;
  529. import org.apache.tools.ant.*;
  530. /**
  531. * A simple listener that waits for a build to finish and sends an email
  532. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  533. * are fairly self explanatory.
  534. *
  535. * @author Will Glozer
  536. * @version 1.05a 09/06/2000
  537. */
  538. public class BuildMonitor implements BuildListener {
  539. protected Properties props;
  540. /**
  541. * Create a new BuildMonitor.
  542. */
  543. public BuildMonitor() throws Exception {
  544. props = new Properties();
  545. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  546. props.load(is);
  547. is.close();
  548. }
  549. public void buildStarted(BuildEvent e) {
  550. }
  551. /**
  552. * Determine the status of the build and the actions to follow, now that
  553. * the build has completed.
  554. *
  555. * @param e Event describing the build tatus.
  556. */
  557. public void buildFinished(BuildEvent e) {
  558. Throwable th = e.getException();
  559. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  560. try {
  561. String key = &quot;build.&quot; + status;
  562. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  563. return;
  564. }
  565. Session session = Session.getDefaultInstance(props, null);
  566. MimeMessage message = new MimeMessage(session);
  567. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  568. props.getProperty(key + &quot;.email.to&quot;)));
  569. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  570. BufferedReader br = new BufferedReader(new FileReader(
  571. props.getProperty(&quot;build.log&quot;)));
  572. StringWriter sw = new StringWriter();
  573. String line = br.readLine();
  574. while (line != null) {
  575. sw.write(line);
  576. sw.write(&quot;\n&quot;);
  577. line = br.readLine();
  578. }
  579. br.close();
  580. message.setText(sw.toString(), &quot;UTF-8&quot;);
  581. sw.close();
  582. Transport transport = session.getTransport();
  583. transport.connect();
  584. transport.send(message);
  585. transport.close();
  586. } catch (Exception ex) {
  587. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  588. ex.printStackTrace();
  589. }
  590. }
  591. /**
  592. * Parse a comma separated list of internet email addresses.
  593. *
  594. * @param s The list of addresses.
  595. * @return Array of Addresses.
  596. */
  597. protected Address[] parseAddresses(String s) throws Exception {
  598. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  599. Address[] addrs = new Address[st.countTokens()];
  600. for (int i = 0; i &lt; addrs.length; i++) {
  601. addrs[i] = new InternetAddress(st.nextToken());
  602. }
  603. return addrs;
  604. }
  605. public void messageLogged(BuildEvent e) {
  606. }
  607. public void targetStarted(BuildEvent e) {
  608. }
  609. public void targetFinished(BuildEvent e) {
  610. }
  611. public void taskStarted(BuildEvent e) {
  612. }
  613. public void taskFinished(BuildEvent e) {
  614. }
  615. }
  616. </pre></td>
  617. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  618. </tr>
  619. <tr>
  620. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  621. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  622. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  623. </tr>
  624. </table>
  625. </div>
  626. <p>With a <code>monitor.properties</code> like this</p>
  627. <div align="left">
  628. <table cellspacing="4" cellpadding="0" border="0">
  629. <tr>
  630. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  631. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  632. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  633. </tr>
  634. <tr>
  635. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  636. <td bgcolor="#ffffff"><pre>
  637. # configuration for build monitor
  638. mail.transport.protocol=smtp
  639. mail.smtp.host=&lt;host&gt;
  640. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  641. build.log=build.log
  642. build.failed.notify=true
  643. build.failed.email.to=will.glozer@jda.com
  644. build.failed.email.subject=Nightly build failed!
  645. build.succeeded.notify=true
  646. build.succeeded.email.to=will.glozer@jda.com
  647. build.succeeded.email.subject=Nightly build succeeded!
  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><code>monitor.properties</code> should be placed right next
  659. to your compiled <code>BuildMonitor.class</code>. To use it,
  660. invoke Ant like</p>
  661. <div align="left">
  662. <table cellspacing="4" cellpadding="0" border="0">
  663. <tr>
  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. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  666. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  667. </tr>
  668. <tr>
  669. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  670. <td bgcolor="#ffffff"><pre>
  671. ant -listener BuildMonitor
  672. </pre></td>
  673. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  674. </tr>
  675. <tr>
  676. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  677. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  678. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  679. </tr>
  680. </table>
  681. </div>
  682. </blockquote>
  683. </td></tr>
  684. </table>
  685. </a>
  686. <a name="remove-cr">
  687. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  688. <tr><td bgcolor="#828DA6">
  689. <font color="#ffffff" face="arial,helvetica,sanserif">
  690. <strong>
  691. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  692. 1.3 on Unix
  693. </strong>
  694. </font>
  695. </td></tr>
  696. <tr><td>
  697. <blockquote>
  698. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  699. has DOS instead of Unix line endings, you must remove the
  700. carriage return characters from this file. This can be done by
  701. using Ant's &lt;fixcrlf&gt; task or something like:</p>
  702. <div align="left">
  703. <table cellspacing="4" cellpadding="0" border="0">
  704. <tr>
  705. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  706. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  707. <td bgcolor="#023264" width="1" height="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"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  711. <td bgcolor="#ffffff"><pre>
  712. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  713. mv /tmp/foo $ANT_HOME/bin/antRun
  714. </pre></td>
  715. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  716. </tr>
  717. <tr>
  718. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  719. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  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. </tr>
  722. </table>
  723. </div>
  724. </blockquote>
  725. </td></tr>
  726. </table>
  727. </a>
  728. <a name="javadoc-cannot-execute">
  729. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  730. <tr><td bgcolor="#828DA6">
  731. <font color="#ffffff" face="arial,helvetica,sanserif">
  732. <strong>
  733. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  734. </strong>
  735. </font>
  736. </td></tr>
  737. <tr><td>
  738. <blockquote>
  739. <p>There is a bug in the Solaris reference implementation of
  740. 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>.
  741. This also appears to be true under Linux, moving the JDK to
  742. the front of the PATH fixes the problem.</p>
  743. </blockquote>
  744. </td></tr>
  745. </table>
  746. </a>
  747. </blockquote>
  748. </td></tr>
  749. </table>
  750. </td>
  751. </tr>
  752. <!-- FOOTER -->
  753. <tr><td colspan="2">
  754. <hr noshade="" size="1"/>
  755. </td></tr>
  756. <tr><td colspan="2">
  757. <div align="center"><font color="#525D76" size="-1"><em>
  758. Copyright &#169; 1999-2001, Apache Software Foundation
  759. </em></font></div>
  760. </td></tr>
  761. </table>
  762. </body>
  763. </html>
  764. <!-- end the processing -->