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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386
  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>Apache 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/index.html">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. <li> <a href="./problems.html">Having Problems?</a>
  42. </li>
  43. </ul>
  44. <p><strong>Download</strong></p>
  45. <ul>
  46. <li> <a href="http://jakarta.apache.org/site/binindex.html">Binaries</a>
  47. </li>
  48. <li> <a href="http://jakarta.apache.org/site/sourceindex.html">Source Code</a>
  49. </li>
  50. </ul>
  51. <p><strong>Jakarta</strong></p>
  52. <ul>
  53. <li> <a href="http://jakarta.apache.org/site/news.html">News & Status</a>
  54. </li>
  55. <li> <a href="http://jakarta.apache.org/site/mission.html">Mission</a>
  56. </li>
  57. <li> <a href="http://jakarta.apache.org/site/guidelines.html">Guidelines Notes</a>
  58. </li>
  59. <li> <a href="http://jakarta.apache.org/site/faqs.html">FAQs</a>
  60. </li>
  61. </ul>
  62. <p><strong>Get Involved</strong></p>
  63. <ul>
  64. <li> <a href="http://jakarta.apache.org/site/getinvolved.html">Overview</a>
  65. </li>
  66. <li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a>
  67. </li>
  68. <li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
  69. </li>
  70. <li> <a href="http://jakarta.apache.org/site/library.html">Reference Library</a>
  71. </li>
  72. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant">Bug Database</a>
  73. </li>
  74. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant&bug_severity=Enhancement">Enhancement Requests</a>
  75. </li>
  76. </ul>
  77. </td>
  78. <td align="left" valign="top">
  79. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  80. <tr><td bgcolor="#525D76">
  81. <font color="#ffffff" face="arial,helvetica,sanserif">
  82. <strong>Questions</strong>
  83. </font>
  84. </td></tr>
  85. <tr><td>
  86. <blockquote>
  87. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  88. <tr><td bgcolor="#828DA6">
  89. <font color="#ffffff" face="arial,helvetica,sanserif">
  90. <strong>About this FAQ</strong>
  91. </font>
  92. </td></tr>
  93. <tr><td>
  94. <blockquote>
  95. <ul>
  96. <li><a href="#latest-version">
  97. Where do I find the latest version of this
  98. document?
  99. </a></li>
  100. <li><a href="#adding-faqs">
  101. How can I contribute to this FAQ?
  102. </a></li>
  103. </ul>
  104. </blockquote>
  105. </td></tr>
  106. </table>
  107. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  108. <tr><td bgcolor="#828DA6">
  109. <font color="#ffffff" face="arial,helvetica,sanserif">
  110. <strong>General</strong>
  111. </font>
  112. </td></tr>
  113. <tr><td>
  114. <blockquote>
  115. <ul>
  116. <li><a href="#what-is-ant">
  117. What is Apache Ant?
  118. </a></li>
  119. <li><a href="#ant-name">
  120. Why do you call it Ant?
  121. </a></li>
  122. <li><a href="#history">
  123. Tell us a little bit about Ant's history.
  124. </a></li>
  125. </ul>
  126. </blockquote>
  127. </td></tr>
  128. </table>
  129. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  130. <tr><td bgcolor="#828DA6">
  131. <font color="#ffffff" face="arial,helvetica,sanserif">
  132. <strong>Installation</strong>
  133. </font>
  134. </td></tr>
  135. <tr><td>
  136. <blockquote>
  137. <ul>
  138. <li><a href="#no-gnu-tar">
  139. I get checksum errors when I try to extract the
  140. <code>tar.gz</code> distribution file. Why?
  141. </a></li>
  142. </ul>
  143. </blockquote>
  144. </td></tr>
  145. </table>
  146. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  147. <tr><td bgcolor="#828DA6">
  148. <font color="#ffffff" face="arial,helvetica,sanserif">
  149. <strong>Using Ant</strong>
  150. </font>
  151. </td></tr>
  152. <tr><td>
  153. <blockquote>
  154. <ul>
  155. <li><a href="#always-recompiles">
  156. Why does Ant always recompile all my Java files?
  157. </a></li>
  158. <li><a href="#passing-cli-args">
  159. How do I pass parameters from the command line to my
  160. build file?
  161. </a></li>
  162. <li><a href="#jikes-switches">
  163. How can I use Jikes specific command line
  164. switches?
  165. </a></li>
  166. <li><a href="#shell-redirect-1">
  167. How do I include a &lt; character in my command line arguments?
  168. </a></li>
  169. <li><a href="#shell-redirect-2">
  170. How do I redirect standard input or standard output
  171. in the <code>&lt;exec&gt;</code> task?
  172. </a></li>
  173. <li><a href="#defaultexcludes">
  174. I've made a &lt;delete&gt; task to delete unwanted
  175. sourcesafe control files (CVS files, editor backup files), but
  176. it doesn't seem to work. The files never get deleted. What's
  177. wrong?
  178. </a></li>
  179. </ul>
  180. </blockquote>
  181. </td></tr>
  182. </table>
  183. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  184. <tr><td bgcolor="#828DA6">
  185. <font color="#ffffff" face="arial,helvetica,sanserif">
  186. <strong>Ant and IDEs/Editors</strong>
  187. </font>
  188. </td></tr>
  189. <tr><td>
  190. <blockquote>
  191. <ul>
  192. <li><a href="#integration">
  193. Is Ant supported by my IDE/Editor?
  194. </a></li>
  195. <li><a href="#emacs-mode">
  196. Why doesn't (X)Emacs/vi/MacOS X's project builder
  197. parse the error messages generated by Ant correctly?
  198. </a></li>
  199. </ul>
  200. </blockquote>
  201. </td></tr>
  202. </table>
  203. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  204. <tr><td bgcolor="#828DA6">
  205. <font color="#ffffff" face="arial,helvetica,sanserif">
  206. <strong>Advanced issues</strong>
  207. </font>
  208. </td></tr>
  209. <tr><td>
  210. <blockquote>
  211. <ul>
  212. <li><a href="#dtd">
  213. Is there a DTD that I can use to validate my build
  214. files?
  215. </a></li>
  216. <li><a href="#xml-entity-include">
  217. How do I include an XML snippet in my build file?
  218. </a></li>
  219. <li><a href="#mail-logger">
  220. How do I send an email with the result of my build
  221. process?
  222. </a></li>
  223. </ul>
  224. </blockquote>
  225. </td></tr>
  226. </table>
  227. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  228. <tr><td bgcolor="#828DA6">
  229. <font color="#ffffff" face="arial,helvetica,sanserif">
  230. <strong>Known problems</strong>
  231. </font>
  232. </td></tr>
  233. <tr><td>
  234. <blockquote>
  235. <ul>
  236. <li><a href="#remove-cr">
  237. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  238. 1.3 on Unix
  239. </a></li>
  240. <li><a href="#javadoc-cannot-execute">
  241. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  242. </a></li>
  243. </ul>
  244. </blockquote>
  245. </td></tr>
  246. </table>
  247. </blockquote>
  248. </td></tr>
  249. </table>
  250. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  251. <tr><td bgcolor="#525D76">
  252. <font color="#ffffff" face="arial,helvetica,sanserif">
  253. <strong>Answers</strong>
  254. </font>
  255. </td></tr>
  256. <tr><td>
  257. <blockquote>
  258. <a name="latest-version">
  259. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  260. <tr><td bgcolor="#828DA6">
  261. <font color="#ffffff" face="arial,helvetica,sanserif">
  262. <strong>
  263. Where do I find the latest version of this
  264. document?
  265. </strong>
  266. </font>
  267. </td></tr>
  268. <tr><td>
  269. <blockquote>
  270. <p>The latest version can always be found at Ant's homepage
  271. <a href="http://jakarta.apache.org/ant/faq.html">http://jakarta.apache.org/ant/faq.html</a>.</p>
  272. </blockquote>
  273. </td></tr>
  274. </table>
  275. </a>
  276. <a name="adding-faqs">
  277. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  278. <tr><td bgcolor="#828DA6">
  279. <font color="#ffffff" face="arial,helvetica,sanserif">
  280. <strong>
  281. How can I contribute to this FAQ?
  282. </strong>
  283. </font>
  284. </td></tr>
  285. <tr><td>
  286. <blockquote>
  287. <p>The page you are looking it is generated from
  288. <a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/jakarta-ant/xdocs/faq.xml">this</a>
  289. document. If you want to add a new question, please submit
  290. a patch against this document, the structure is hoped to be
  291. self-explaining.</p>
  292. </blockquote>
  293. </td></tr>
  294. </table>
  295. </a>
  296. <a name="what-is-ant">
  297. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  298. <tr><td bgcolor="#828DA6">
  299. <font color="#ffffff" face="arial,helvetica,sanserif">
  300. <strong>
  301. What is Apache Ant?
  302. </strong>
  303. </font>
  304. </td></tr>
  305. <tr><td>
  306. <blockquote>
  307. <p> Ant is a Java based build tool. In theory it is kind of
  308. like "make" without makes wrinkles and with the full
  309. portability of pure Java code.</p>
  310. </blockquote>
  311. </td></tr>
  312. </table>
  313. </a>
  314. <a name="ant-name">
  315. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  316. <tr><td bgcolor="#828DA6">
  317. <font color="#ffffff" face="arial,helvetica,sanserif">
  318. <strong>
  319. Why do you call it Ant?
  320. </strong>
  321. </font>
  322. </td></tr>
  323. <tr><td>
  324. <blockquote>
  325. <p>According to Ant's original author James Duncan
  326. Davidson, the name is an acronym for "Another Neat
  327. Tool".</p>
  328. <p>Later explanations go along the lines of "Ants are
  329. doing an extremely good job at building things" or
  330. "Ants are very small and can carry a weight a dozen times
  331. of their own" - describing what Ant is intended to
  332. be.</p>
  333. </blockquote>
  334. </td></tr>
  335. </table>
  336. </a>
  337. <a name="history">
  338. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  339. <tr><td bgcolor="#828DA6">
  340. <font color="#ffffff" face="arial,helvetica,sanserif">
  341. <strong>
  342. Tell us a little bit about Ant's history.
  343. </strong>
  344. </font>
  345. </td></tr>
  346. <tr><td>
  347. <blockquote>
  348. <p>Initially Ant was part of the Tomcat code base when it was
  349. donated to the Apache Software Foundation - it has been
  350. created by James Duncan Davidson, who also is the original
  351. author of Tomcat. Ant was there to build Tomcat, nothing
  352. else.</p>
  353. <p>Soon thereafter several open source Java projects realized
  354. that Ant could solve the problems they had with makefiles.
  355. Starting with the projects hosted at Jakarta and the old Java
  356. Apache project, Ant spread like a virus and now is the build
  357. tool of choice for a lot of projects.</p>
  358. <p>In January 2000 Ant was moved to a separate CVS module and
  359. was promoted to a project of its own, independent of
  360. Tomcat. Ant became Apache Ant.</p>
  361. <p>The first version of Ant that was exposed a lager audience
  362. was the one that shipped with Tomcat's 3.1 release on 19 April
  363. 2000. This version has later been referenced to as Ant
  364. 0.3.1.</p>
  365. <p>The first official release of Ant as a stand alone product was
  366. Ant 1.1 released on 19 July 2000. The complete release
  367. history:</p>
  368. <table>
  369. <tr>
  370. <td bgcolor="#039acc" colspan="" rowspan=""
  371. valign="top" align="left">
  372. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  373. Ant Version
  374. </font>
  375. </td>
  376. <td bgcolor="#039acc" colspan="" rowspan=""
  377. valign="top" align="left">
  378. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  379. Release Date
  380. </font>
  381. </td>
  382. </tr>
  383. <tr>
  384. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  385. valign="top" align="left">
  386. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  387. 1.1
  388. </font>
  389. </td>
  390. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  391. valign="top" align="left">
  392. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  393. 19 July 2000
  394. </font>
  395. </td>
  396. </tr>
  397. <tr>
  398. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  399. valign="top" align="left">
  400. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  401. 1.2
  402. </font>
  403. </td>
  404. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  405. valign="top" align="left">
  406. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  407. 24 October 2000
  408. </font>
  409. </td>
  410. </tr>
  411. <tr>
  412. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  413. valign="top" align="left">
  414. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  415. 1.3
  416. </font>
  417. </td>
  418. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  419. valign="top" align="left">
  420. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  421. 3 March 2001
  422. </font>
  423. </td>
  424. </tr>
  425. <tr>
  426. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  427. valign="top" align="left">
  428. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  429. 1.4
  430. </font>
  431. </td>
  432. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  433. valign="top" align="left">
  434. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  435. 3 September 2001
  436. </font>
  437. </td>
  438. </tr>
  439. <tr>
  440. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  441. valign="top" align="left">
  442. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  443. 1.4.1
  444. </font>
  445. </td>
  446. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  447. valign="top" align="left">
  448. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  449. 11 October 2001
  450. </font>
  451. </td>
  452. </tr>
  453. </table>
  454. </blockquote>
  455. </td></tr>
  456. </table>
  457. </a>
  458. <a name="no-gnu-tar">
  459. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  460. <tr><td bgcolor="#828DA6">
  461. <font color="#ffffff" face="arial,helvetica,sanserif">
  462. <strong>
  463. I get checksum errors when I try to extract the
  464. <code>tar.gz</code> distribution file. Why?
  465. </strong>
  466. </font>
  467. </td></tr>
  468. <tr><td>
  469. <blockquote>
  470. <p>Ant's distribution contains file names that are longer
  471. than 100 characters, which is not supported by the standard
  472. tar file format. Several different implementations of tar use
  473. different and incompatible ways to work around this
  474. restriction.</p>
  475. <p>Ant's &lt;tar&gt; task can create tar archives that use
  476. the GNU tar extension, and this has been used when putting
  477. together the distribution. If you are using a different
  478. version of tar (for example, the one shipping with Solaris),
  479. you cannot use it to extract the archive.</p>
  480. <p>The solution is to either install GNU tar, which can be
  481. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
  482. or use the zip archive instead (you can extract it using
  483. <code>jar xf</code>).</p>
  484. </blockquote>
  485. </td></tr>
  486. </table>
  487. </a>
  488. <a name="always-recompiles">
  489. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  490. <tr><td bgcolor="#828DA6">
  491. <font color="#ffffff" face="arial,helvetica,sanserif">
  492. <strong>
  493. Why does Ant always recompile all my Java files?
  494. </strong>
  495. </font>
  496. </td></tr>
  497. <tr><td>
  498. <blockquote>
  499. <p>In order to find out which files should be compiled, Ant
  500. compares the timestamps of the source files to those of the
  501. resulting <code>.class</code> files. Opening all source files
  502. to find out which package they belong to would be very
  503. inefficient - instead of this, Ant expects you to place your
  504. source files in a directory hierarchy that mirrors your
  505. package hierarchy and to point Ant to the root of this
  506. directory tree with the <code>srcdir</code> attribute.</p>
  507. <p>Say you have <code>&lt;javac srcdir="src"
  508. destdir="dest" /&gt;</code>. If Ant finds a file
  509. <code>src/a/b/C.java</code> it expects it to be in package
  510. <code>a.b</code> so that the resulting <code>.class</code>
  511. file is going to be <code>dest/a/b/C.class</code>.</p>
  512. <p>If your setup is different, Ant's heuristic won't work and
  513. it will recompile classes that are up to date. Ant is not the
  514. only tool, that expects a source tree layout like this.</p>
  515. </blockquote>
  516. </td></tr>
  517. </table>
  518. </a>
  519. <a name="passing-cli-args">
  520. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  521. <tr><td bgcolor="#828DA6">
  522. <font color="#ffffff" face="arial,helvetica,sanserif">
  523. <strong>
  524. How do I pass parameters from the command line to my
  525. build file?
  526. </strong>
  527. </font>
  528. </td></tr>
  529. <tr><td>
  530. <blockquote>
  531. <p>Use properties: <code>ant
  532. -D&lt;name&gt;=&lt;value&gt;</code> lets you define values for
  533. properties. These can then be used within your build file as
  534. any normal property: <code>${&lt;name&gt;}</code> will put in
  535. <code>&lt;value&gt;</code>.</p>
  536. </blockquote>
  537. </td></tr>
  538. </table>
  539. </a>
  540. <a name="jikes-switches">
  541. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  542. <tr><td bgcolor="#828DA6">
  543. <font color="#ffffff" face="arial,helvetica,sanserif">
  544. <strong>
  545. How can I use Jikes specific command line
  546. switches?
  547. </strong>
  548. </font>
  549. </td></tr>
  550. <tr><td>
  551. <blockquote>
  552. <p>A couple of switches are supported via magic
  553. properties:</p>
  554. <table>
  555. <tr>
  556. <td bgcolor="#039acc" colspan="" rowspan=""
  557. valign="top" align="left">
  558. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  559. switch
  560. </font>
  561. </td>
  562. <td bgcolor="#039acc" colspan="" rowspan=""
  563. valign="top" align="left">
  564. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  565. property
  566. </font>
  567. </td>
  568. <td bgcolor="#039acc" colspan="" rowspan=""
  569. valign="top" align="left">
  570. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  571. default
  572. </font>
  573. </td>
  574. </tr>
  575. <tr>
  576. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  577. valign="top" align="left">
  578. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  579. +E
  580. </font>
  581. </td>
  582. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  583. valign="top" align="left">
  584. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  585. build.compiler.emacs
  586. </font>
  587. </td>
  588. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  589. valign="top" align="left">
  590. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  591. false == not set
  592. </font>
  593. </td>
  594. </tr>
  595. <tr>
  596. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  597. valign="top" align="left">
  598. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  599. +P
  600. </font>
  601. </td>
  602. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  603. valign="top" align="left">
  604. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  605. build.compiler.pedantic
  606. </font>
  607. </td>
  608. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  609. valign="top" align="left">
  610. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  611. false == not set
  612. </font>
  613. </td>
  614. </tr>
  615. <tr>
  616. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  617. valign="top" align="left">
  618. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  619. +F
  620. </font>
  621. </td>
  622. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  623. valign="top" align="left">
  624. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  625. build.compiler.fulldepend
  626. </font>
  627. </td>
  628. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  629. valign="top" align="left">
  630. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  631. false == not set
  632. </font>
  633. </td>
  634. </tr>
  635. <tr>
  636. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  637. valign="top" align="left">
  638. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  639. <strong>only for Ant &lt; 1.4, replaced by the nowarn
  640. attribute of javac after that</strong> -nowarn
  641. </font>
  642. </td>
  643. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  644. valign="top" align="left">
  645. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  646. build.compiler.warnings
  647. </font>
  648. </td>
  649. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  650. valign="top" align="left">
  651. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  652. true == not set
  653. </font>
  654. </td>
  655. </tr>
  656. </table>
  657. </blockquote>
  658. </td></tr>
  659. </table>
  660. </a>
  661. <a name="shell-redirect-1">
  662. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  663. <tr><td bgcolor="#828DA6">
  664. <font color="#ffffff" face="arial,helvetica,sanserif">
  665. <strong>
  666. How do I include a &lt; character in my command line arguments?
  667. </strong>
  668. </font>
  669. </td></tr>
  670. <tr><td>
  671. <blockquote>
  672. <p>The short answer is "Use <code>&amp;lt;</code>".</p>
  673. <p>The long answer is, that this probably won't do what you
  674. want anyway, see <a href="#shell-redirect-2">the next
  675. section</a>.</p>
  676. </blockquote>
  677. </td></tr>
  678. </table>
  679. </a>
  680. <a name="shell-redirect-2">
  681. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  682. <tr><td bgcolor="#828DA6">
  683. <font color="#ffffff" face="arial,helvetica,sanserif">
  684. <strong>
  685. How do I redirect standard input or standard output
  686. in the <code>&lt;exec&gt;</code> task?
  687. </strong>
  688. </font>
  689. </td></tr>
  690. <tr><td>
  691. <blockquote>
  692. <p>Say you want to redirect the standard input stream of the
  693. <code>cat</code> command to read from a file, something
  694. like</p>
  695. <div align="left">
  696. <table cellspacing="4" cellpadding="0" border="0">
  697. <tr>
  698. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  699. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  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. </tr>
  702. <tr>
  703. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  704. <td bgcolor="#ffffff"><pre>
  705. shell-prompt&gt; cat &lt; foo
  706. </pre></td>
  707. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  708. </tr>
  709. <tr>
  710. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  711. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  712. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  713. </tr>
  714. </table>
  715. </div>
  716. <p>and try to translate it into</p>
  717. <div align="left">
  718. <table cellspacing="4" cellpadding="0" border="0">
  719. <tr>
  720. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  721. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  722. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  723. </tr>
  724. <tr>
  725. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  726. <td bgcolor="#ffffff"><pre>
  727. &lt;exec executable=&quot;cat&quot;&gt;
  728. &lt;arg value=&quot;&amp;lt;&quot; /&gt;
  729. &lt;arg value=&quot;foo&quot; /&gt;
  730. &lt;/exec&gt;
  731. </pre></td>
  732. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  733. </tr>
  734. <tr>
  735. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  736. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  737. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  738. </tr>
  739. </table>
  740. </div>
  741. <p>This will not do what you expect. The input-redirection is
  742. performed by your shell, not the command itself, so this
  743. should read:</p>
  744. <div align="left">
  745. <table cellspacing="4" cellpadding="0" border="0">
  746. <tr>
  747. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  748. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  749. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  750. </tr>
  751. <tr>
  752. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  753. <td bgcolor="#ffffff"><pre>
  754. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  755. &lt;arg value=&quot;-c&quot; /&gt;
  756. &lt;arg value=&quot;cat &amp;lt; foo&quot; /&gt;
  757. &lt;/exec&gt;
  758. </pre></td>
  759. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  760. </tr>
  761. <tr>
  762. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  763. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  764. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  765. </tr>
  766. </table>
  767. </div>
  768. <p>Note, that you must use the <code>value</code> attribute of
  769. <code>&lt;arg&gt;</code> in the last element.</p>
  770. </blockquote>
  771. </td></tr>
  772. </table>
  773. </a>
  774. <a name="defaultexcludes">
  775. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  776. <tr><td bgcolor="#828DA6">
  777. <font color="#ffffff" face="arial,helvetica,sanserif">
  778. <strong>
  779. I've made a &lt;delete&gt; task to delete unwanted
  780. sourcesafe control files (CVS files, editor backup files), but
  781. it doesn't seem to work. The files never get deleted. What's
  782. wrong?
  783. </strong>
  784. </font>
  785. </td></tr>
  786. <tr><td>
  787. <blockquote>
  788. <p>This is probably happening because by default, Ant excludes
  789. SourceSafe control files (<code>vssver.scc</code>) and other
  790. files from FileSets.</p>
  791. <p>Here's what you probably did:</p>
  792. <div align="left">
  793. <table cellspacing="4" cellpadding="0" border="0">
  794. <tr>
  795. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  796. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  797. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  798. </tr>
  799. <tr>
  800. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  801. <td bgcolor="#ffffff"><pre>
  802. &lt;delete&gt;
  803. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  804. &lt;/delete&gt;
  805. </pre></td>
  806. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  807. </tr>
  808. <tr>
  809. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  810. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  811. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  812. </tr>
  813. </table>
  814. </div>
  815. <p>You need to switch off the default exclusions and it will work:</p>
  816. <div align="left">
  817. <table cellspacing="4" cellpadding="0" border="0">
  818. <tr>
  819. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  820. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  821. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  822. </tr>
  823. <tr>
  824. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  825. <td bgcolor="#ffffff"><pre>
  826. &lt;delete&gt;
  827. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  828. defaultexcludes=&quot;no&quot;/&gt;
  829. &lt;/delete&gt;
  830. </pre></td>
  831. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  832. </tr>
  833. <tr>
  834. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  835. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  836. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  837. </tr>
  838. </table>
  839. </div>
  840. <p>For a complete listing of the patterns that are excluded
  841. by default, see <a href="manual/dirtasks.html">the user
  842. manual</a>.</p>
  843. </blockquote>
  844. </td></tr>
  845. </table>
  846. </a>
  847. <a name="integration">
  848. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  849. <tr><td bgcolor="#828DA6">
  850. <font color="#ffffff" face="arial,helvetica,sanserif">
  851. <strong>
  852. Is Ant supported by my IDE/Editor?
  853. </strong>
  854. </font>
  855. </td></tr>
  856. <tr><td>
  857. <blockquote>
  858. <p>See the <a href="external.html#IDE and Editor Integration">section
  859. on IDE integration</a> on our external tools page.</p>
  860. </blockquote>
  861. </td></tr>
  862. </table>
  863. </a>
  864. <a name="emacs-mode">
  865. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  866. <tr><td bgcolor="#828DA6">
  867. <font color="#ffffff" face="arial,helvetica,sanserif">
  868. <strong>
  869. Why doesn't (X)Emacs/vi/MacOS X's project builder
  870. parse the error messages generated by Ant correctly?
  871. </strong>
  872. </font>
  873. </td></tr>
  874. <tr><td>
  875. <blockquote>
  876. <p>Ant adds a "banner" with the name of the current
  877. task in front of all messages - and there are no built-in
  878. regular expressions in your Editor that would account for
  879. this.</p>
  880. <p>You can disable this banner by invoking Ant with the
  881. <code>-emacs</code> switch. Alternatively you can add the
  882. following snippet to your <code>.emacs</code> to make Emacs
  883. understand Ant's output.</p>
  884. <div align="left">
  885. <table cellspacing="4" cellpadding="0" border="0">
  886. <tr>
  887. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  888. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  889. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  890. </tr>
  891. <tr>
  892. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  893. <td bgcolor="#ffffff"><pre>
  894. (require 'compile)
  895. (setq compilation-error-regexp-alist
  896. (append (list
  897. ;; works for jikes
  898. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  899. ;; works for javac
  900. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  901. compilation-error-regexp-alist))
  902. </pre></td>
  903. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  904. </tr>
  905. <tr>
  906. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  907. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  908. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  909. </tr>
  910. </table>
  911. </div>
  912. <p>Yet another alternative that preserves most of Ant's
  913. formatting is to pipe Ant's output through the following Perl
  914. script by Dirk-Willem van Gulik:</p>
  915. <div align="left">
  916. <table cellspacing="4" cellpadding="0" border="0">
  917. <tr>
  918. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  919. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  920. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  921. </tr>
  922. <tr>
  923. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  924. <td bgcolor="#ffffff"><pre>
  925. #!/usr/bin/perl
  926. #
  927. # May 2001 dirkx@apache.org - remove any
  928. # [foo] lines from the output; keeping
  929. # spacing more or less there.
  930. #
  931. $|=1;
  932. while(&lt;STDIN&gt;) {
  933. if (s/^(\s+)\[(\w+)\]//) {
  934. if ($2 ne $last) {
  935. print &quot;$1\[$2\]&quot;;
  936. $s = ' ' x length($2);
  937. } else {
  938. print &quot;$1 $s &quot;;
  939. };
  940. $last = $2;
  941. };
  942. print;
  943. };
  944. </pre></td>
  945. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  946. </tr>
  947. <tr>
  948. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  949. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  950. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  951. </tr>
  952. </table>
  953. </div>
  954. </blockquote>
  955. </td></tr>
  956. </table>
  957. </a>
  958. <a name="dtd">
  959. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  960. <tr><td bgcolor="#828DA6">
  961. <font color="#ffffff" face="arial,helvetica,sanserif">
  962. <strong>
  963. Is there a DTD that I can use to validate my build
  964. files?
  965. </strong>
  966. </font>
  967. </td></tr>
  968. <tr><td>
  969. <blockquote>
  970. <p>An incomplete DTD can be created by the
  971. <code>&lt;antstructure&gt;</code> task - but this one
  972. has a few problems:</p>
  973. <ul>
  974. <li>It doesn't know about required attributes. Only
  975. manual tweaking of this file can help here.</li>
  976. <li>It is not complete - if you add new tasks via
  977. <code>&lt;taskdef&gt;</code> it won't know about it. See
  978. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  979. page</a> by Michel Casabianca for a solution to this
  980. problem. Note that the DTD you can download at this page
  981. is based on Ant 0.3.1.</li>
  982. <li>It may even be an invalid DTD. As Ant allows tasks
  983. writers to define arbitrary elements, name collisions will
  984. happen quite frequently - if your version of Ant contains
  985. the optional <code>&lt;test&gt;</code> and
  986. <code>&lt;junit&gt;</code> tasks, there are two XML
  987. elements named test (the task and the nested child element
  988. of <code>&lt;junit&gt;</code>) with different attribute
  989. lists. This problem cannot be solved, DTDs don't give a
  990. syntax rich enough to support this.</li>
  991. </ul>
  992. </blockquote>
  993. </td></tr>
  994. </table>
  995. </a>
  996. <a name="xml-entity-include">
  997. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  998. <tr><td bgcolor="#828DA6">
  999. <font color="#ffffff" face="arial,helvetica,sanserif">
  1000. <strong>
  1001. How do I include an XML snippet in my build file?
  1002. </strong>
  1003. </font>
  1004. </td></tr>
  1005. <tr><td>
  1006. <blockquote>
  1007. <p>You can use XML's way of including external files and let
  1008. the parser do the job for Ant:</p>
  1009. <div align="left">
  1010. <table cellspacing="4" cellpadding="0" border="0">
  1011. <tr>
  1012. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1013. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1014. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1015. </tr>
  1016. <tr>
  1017. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1018. <td bgcolor="#ffffff"><pre>
  1019. &lt;?xml version=&quot;1.0&quot;?&gt;
  1020. &lt;!DOCTYPE project [
  1021. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  1022. ]&gt;
  1023. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1024. &lt;target name=&quot;setup&quot;&gt;
  1025. ...
  1026. &lt;/target&gt;
  1027. &amp;common;
  1028. ...
  1029. &lt;/project&gt;
  1030. </pre></td>
  1031. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1032. </tr>
  1033. <tr>
  1034. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1035. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1036. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1037. </tr>
  1038. </table>
  1039. </div>
  1040. <p>will literally include the contents of <code>common.xml</code> where
  1041. you've placed the <code>&amp;common;</code> entity.</p>
  1042. <p>In combination with a DTD, this would look like this:</p>
  1043. <div align="left">
  1044. <table cellspacing="4" cellpadding="0" border="0">
  1045. <tr>
  1046. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1047. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1048. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1049. </tr>
  1050. <tr>
  1051. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1052. <td bgcolor="#ffffff"><pre>
  1053. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  1054. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  1055. ]&gt;
  1056. </pre></td>
  1057. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1058. </tr>
  1059. <tr>
  1060. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1061. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1062. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1063. </tr>
  1064. </table>
  1065. </div>
  1066. </blockquote>
  1067. </td></tr>
  1068. </table>
  1069. </a>
  1070. <a name="mail-logger">
  1071. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1072. <tr><td bgcolor="#828DA6">
  1073. <font color="#ffffff" face="arial,helvetica,sanserif">
  1074. <strong>
  1075. How do I send an email with the result of my build
  1076. process?
  1077. </strong>
  1078. </font>
  1079. </td></tr>
  1080. <tr><td>
  1081. <blockquote>
  1082. <p>You can use a custom BuildListener, that sends out an email
  1083. in the buildFinished() method. Will Glozer
  1084. &lt;will.glozer@jda.com&gt; has written such a listener based
  1085. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>,
  1086. the source is</p>
  1087. <div align="left">
  1088. <table cellspacing="4" cellpadding="0" border="0">
  1089. <tr>
  1090. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1091. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1092. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1093. </tr>
  1094. <tr>
  1095. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1096. <td bgcolor="#ffffff"><pre>
  1097. import java.io.*;
  1098. import java.util.*;
  1099. import javax.mail.*;
  1100. import javax.mail.internet.*;
  1101. import org.apache.tools.ant.*;
  1102. /**
  1103. * A simple listener that waits for a build to finish and sends an email
  1104. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1105. * are fairly self explanatory.
  1106. *
  1107. * @author Will Glozer
  1108. * @version 1.05a 09/06/2000
  1109. */
  1110. public class BuildMonitor implements BuildListener {
  1111. protected Properties props;
  1112. /**
  1113. * Create a new BuildMonitor.
  1114. */
  1115. public BuildMonitor() throws Exception {
  1116. props = new Properties();
  1117. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1118. props.load(is);
  1119. is.close();
  1120. }
  1121. public void buildStarted(BuildEvent e) {
  1122. }
  1123. /**
  1124. * Determine the status of the build and the actions to follow, now that
  1125. * the build has completed.
  1126. *
  1127. * @param e Event describing the build tatus.
  1128. */
  1129. public void buildFinished(BuildEvent e) {
  1130. Throwable th = e.getException();
  1131. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1132. try {
  1133. String key = &quot;build.&quot; + status;
  1134. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1135. return;
  1136. }
  1137. Session session = Session.getDefaultInstance(props, null);
  1138. MimeMessage message = new MimeMessage(session);
  1139. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1140. props.getProperty(key + &quot;.email.to&quot;)));
  1141. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1142. BufferedReader br = new BufferedReader(new FileReader(
  1143. props.getProperty(&quot;build.log&quot;)));
  1144. StringWriter sw = new StringWriter();
  1145. String line = br.readLine();
  1146. while (line != null) {
  1147. sw.write(line);
  1148. sw.write(&quot;\n&quot;);
  1149. line = br.readLine();
  1150. }
  1151. br.close();
  1152. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1153. sw.close();
  1154. Transport transport = session.getTransport();
  1155. transport.connect();
  1156. transport.send(message);
  1157. transport.close();
  1158. } catch (Exception ex) {
  1159. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1160. ex.printStackTrace();
  1161. }
  1162. }
  1163. /**
  1164. * Parse a comma separated list of internet email addresses.
  1165. *
  1166. * @param s The list of addresses.
  1167. * @return Array of Addresses.
  1168. */
  1169. protected Address[] parseAddresses(String s) throws Exception {
  1170. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1171. Address[] addrs = new Address[st.countTokens()];
  1172. for (int i = 0; i &lt; addrs.length; i++) {
  1173. addrs[i] = new InternetAddress(st.nextToken());
  1174. }
  1175. return addrs;
  1176. }
  1177. public void messageLogged(BuildEvent e) {
  1178. }
  1179. public void targetStarted(BuildEvent e) {
  1180. }
  1181. public void targetFinished(BuildEvent e) {
  1182. }
  1183. public void taskStarted(BuildEvent e) {
  1184. }
  1185. public void taskFinished(BuildEvent e) {
  1186. }
  1187. }
  1188. </pre></td>
  1189. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1190. </tr>
  1191. <tr>
  1192. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1193. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1194. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1195. </tr>
  1196. </table>
  1197. </div>
  1198. <p>With a <code>monitor.properties</code> like this</p>
  1199. <div align="left">
  1200. <table cellspacing="4" cellpadding="0" border="0">
  1201. <tr>
  1202. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1203. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1204. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1205. </tr>
  1206. <tr>
  1207. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1208. <td bgcolor="#ffffff"><pre>
  1209. # configuration for build monitor
  1210. mail.transport.protocol=smtp
  1211. mail.smtp.host=&lt;host&gt;
  1212. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1213. build.log=build.log
  1214. build.failed.notify=true
  1215. build.failed.email.to=will.glozer@jda.com
  1216. build.failed.email.subject=Nightly build failed!
  1217. build.succeeded.notify=true
  1218. build.succeeded.email.to=will.glozer@jda.com
  1219. build.succeeded.email.subject=Nightly build succeeded!
  1220. </pre></td>
  1221. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1222. </tr>
  1223. <tr>
  1224. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1225. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1226. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1227. </tr>
  1228. </table>
  1229. </div>
  1230. <p><code>monitor.properties</code> should be placed right next
  1231. to your compiled <code>BuildMonitor.class</code>. To use it,
  1232. invoke Ant like</p>
  1233. <div align="left">
  1234. <table cellspacing="4" cellpadding="0" border="0">
  1235. <tr>
  1236. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1237. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1238. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1239. </tr>
  1240. <tr>
  1241. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1242. <td bgcolor="#ffffff"><pre>
  1243. ant -listener BuildMonitor
  1244. </pre></td>
  1245. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1246. </tr>
  1247. <tr>
  1248. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1249. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1250. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1251. </tr>
  1252. </table>
  1253. </div>
  1254. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1255. <code>activation.jar</code> from the
  1256. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1257. Beans Activation Framework</a> in your <code>CLASSPATH</code>.</p>
  1258. </blockquote>
  1259. </td></tr>
  1260. </table>
  1261. </a>
  1262. <a name="remove-cr">
  1263. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1264. <tr><td bgcolor="#828DA6">
  1265. <font color="#ffffff" face="arial,helvetica,sanserif">
  1266. <strong>
  1267. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  1268. 1.3 on Unix
  1269. </strong>
  1270. </font>
  1271. </td></tr>
  1272. <tr><td>
  1273. <blockquote>
  1274. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1275. has DOS instead of Unix line endings, you must remove the
  1276. carriage return characters from this file. This can be done by
  1277. using Ant's &lt;fixcrlf&gt; task or something like:</p>
  1278. <div align="left">
  1279. <table cellspacing="4" cellpadding="0" border="0">
  1280. <tr>
  1281. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1282. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1283. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1284. </tr>
  1285. <tr>
  1286. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1287. <td bgcolor="#ffffff"><pre>
  1288. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1289. mv /tmp/foo $ANT_HOME/bin/antRun
  1290. </pre></td>
  1291. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1292. </tr>
  1293. <tr>
  1294. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1295. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1296. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1297. </tr>
  1298. </table>
  1299. </div>
  1300. </blockquote>
  1301. </td></tr>
  1302. </table>
  1303. </a>
  1304. <a name="javadoc-cannot-execute">
  1305. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1306. <tr><td bgcolor="#828DA6">
  1307. <font color="#ffffff" face="arial,helvetica,sanserif">
  1308. <strong>
  1309. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1310. </strong>
  1311. </font>
  1312. </td></tr>
  1313. <tr><td>
  1314. <blockquote>
  1315. <p>There is a bug in the Solaris reference implementation of
  1316. 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>.
  1317. This also appears to be true under Linux, moving the JDK to
  1318. the front of the PATH fixes the problem.</p>
  1319. </blockquote>
  1320. </td></tr>
  1321. </table>
  1322. </a>
  1323. </blockquote>
  1324. </td></tr>
  1325. </table>
  1326. </td>
  1327. </tr>
  1328. <!-- FOOTER -->
  1329. <tr><td colspan="2">
  1330. <hr noshade="" size="1"/>
  1331. </td></tr>
  1332. <tr><td colspan="2">
  1333. <div align="center"><font color="#525D76" size="-1"><em>
  1334. Copyright &#169; 1999-2001, Apache Software Foundation
  1335. </em></font></div>
  1336. </td></tr>
  1337. </table>
  1338. </body>
  1339. </html>
  1340. <!-- end the processing -->