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

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