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 KiB

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