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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- Content Stylesheet for Site -->
  3. <!-- start the processing -->
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  7. <meta name="author" value="Stefan Bodewig">
  8. <meta name="email" value="bodewig@apache.org">
  9. <title>The Jakarta Site - Frequently Asked Questions</title>
  10. </head>
  11. <body bgcolor="#ffffff" text="#000000" link="#525D76">
  12. <table border="0" width="100%" cellspacing="0">
  13. <!-- TOP IMAGE -->
  14. <tr>
  15. <td colspan="2">
  16. <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
  17. </td>
  18. </tr>
  19. </table>
  20. <table border="0" width="100%" cellspacing="4">
  21. <tr><td colspan="2">
  22. <hr noshade="" size="1"/>
  23. </td></tr>
  24. <tr>
  25. <!-- LEFT SIDE NAVIGATION -->
  26. <td valign="top" nowrap="true">
  27. <p><strong>Ant</strong></p>
  28. <ul>
  29. <li> <a href="./index.html">Front Page</a>
  30. </li>
  31. <li> <a href="./antnews.html">News</a>
  32. </li>
  33. <li> <a href="./manual/">Documentation</a>
  34. </li>
  35. <li> <a href="./external.html">External Tools and Tasks</a>
  36. </li>
  37. <li> <a href="./resources.html">Resources</a>
  38. </li>
  39. <li> <a href="./faq.html">Ant FAQ</a>
  40. </li>
  41. </ul>
  42. <p><strong>Download</strong></p>
  43. <ul>
  44. <li> <a href="http://jakarta.apache.org/site/binindex.html">Binaries</a>
  45. </li>
  46. <li> <a href="http://jakarta.apache.org/site/sourceindex.html">Source Code</a>
  47. </li>
  48. </ul>
  49. <p><strong>Jakarta</strong></p>
  50. <ul>
  51. <li> <a href="http://jakarta.apache.org/site/news.html">News & Status</a>
  52. </li>
  53. <li> <a href="http://jakarta.apache.org/site/mission.html">Mission</a>
  54. </li>
  55. <li> <a href="http://jakarta.apache.org/site/guidelines.html">Guidelines Notes</a>
  56. </li>
  57. <li> <a href="http://jakarta.apache.org/site/faqs.html">FAQs</a>
  58. </li>
  59. </ul>
  60. <p><strong>Get Involved</strong></p>
  61. <ul>
  62. <li> <a href="http://jakarta.apache.org/site/getinvolved.html">Overview</a>
  63. </li>
  64. <li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a>
  65. </li>
  66. <li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
  67. </li>
  68. <li> <a href="http://jakarta.apache.org/site/library.html">Reference Library</a>
  69. </li>
  70. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant">Bug Database</a>
  71. </li>
  72. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant&bug_severity=Enhancement">Enhancement Requests</a>
  73. </li>
  74. </ul>
  75. </td>
  76. <td align="left" valign="top">
  77. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  78. <tr><td bgcolor="#525D76">
  79. <font color="#ffffff" face="arial,helvetica,sanserif">
  80. <strong>Questions</strong>
  81. </font>
  82. </td></tr>
  83. <tr><td>
  84. <blockquote>
  85. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  86. <tr><td bgcolor="#828DA6">
  87. <font color="#ffffff" face="arial,helvetica,sanserif">
  88. <strong>General</strong>
  89. </font>
  90. </td></tr>
  91. <tr><td>
  92. <blockquote>
  93. <ul>
  94. <li><a href="#what-is-ant">
  95. What is Ant?
  96. </a></li>
  97. <li><a href="#ant-name">
  98. Why do you call it Ant?
  99. </a></li>
  100. <li><a href="#history">
  101. Tell us a little bit about Ant's history.
  102. </a></li>
  103. </ul>
  104. </blockquote>
  105. </td></tr>
  106. </table>
  107. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  108. <tr><td bgcolor="#828DA6">
  109. <font color="#ffffff" face="arial,helvetica,sanserif">
  110. <strong>Installation</strong>
  111. </font>
  112. </td></tr>
  113. <tr><td>
  114. <blockquote>
  115. <ul>
  116. <li><a href="#no-gnu-tar">
  117. I get checksum errors when I try to extract the
  118. <code>tar.gz</code> distribution file. Why?
  119. </a></li>
  120. </ul>
  121. </blockquote>
  122. </td></tr>
  123. </table>
  124. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  125. <tr><td bgcolor="#828DA6">
  126. <font color="#ffffff" face="arial,helvetica,sanserif">
  127. <strong>Using Ant</strong>
  128. </font>
  129. </td></tr>
  130. <tr><td>
  131. <blockquote>
  132. <ul>
  133. <li><a href="#always-recompiles">
  134. Why does Ant always recompile all my Java files?
  135. </a></li>
  136. <li><a href="#passing-cli-args">
  137. How do I pass parameters from the command line to my
  138. build file?
  139. </a></li>
  140. <li><a href="#jikes-switches">
  141. How can I use Jikes specific command line
  142. switches?
  143. </a></li>
  144. </ul>
  145. </blockquote>
  146. </td></tr>
  147. </table>
  148. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  149. <tr><td bgcolor="#828DA6">
  150. <font color="#ffffff" face="arial,helvetica,sanserif">
  151. <strong>Ant and IDEs/Editors</strong>
  152. </font>
  153. </td></tr>
  154. <tr><td>
  155. <blockquote>
  156. <ul>
  157. <li><a href="#integration">
  158. Is Ant supported by my IDE/Editor?
  159. </a></li>
  160. <li><a href="#emacs-mode">
  161. Why doesn't (X)Emacs parse the error messages generated
  162. by Ant correctly?
  163. </a></li>
  164. </ul>
  165. </blockquote>
  166. </td></tr>
  167. </table>
  168. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  169. <tr><td bgcolor="#828DA6">
  170. <font color="#ffffff" face="arial,helvetica,sanserif">
  171. <strong>Advanced issues</strong>
  172. </font>
  173. </td></tr>
  174. <tr><td>
  175. <blockquote>
  176. <ul>
  177. <li><a href="#dtd">
  178. Is there a DTD that I can use to validate my build
  179. files?
  180. </a></li>
  181. <li><a href="#xml-entity-include">
  182. How do I include an XML snippet in my build file?
  183. </a></li>
  184. <li><a href="#mail-logger">
  185. How do I send an email with the result of my build
  186. process?
  187. </a></li>
  188. </ul>
  189. </blockquote>
  190. </td></tr>
  191. </table>
  192. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  193. <tr><td bgcolor="#828DA6">
  194. <font color="#ffffff" face="arial,helvetica,sanserif">
  195. <strong>Known problems</strong>
  196. </font>
  197. </td></tr>
  198. <tr><td>
  199. <blockquote>
  200. <ul>
  201. <li><a href="#remove-cr">
  202. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  203. 1.3 on Unix
  204. </a></li>
  205. <li><a href="#javadoc-cannot-execute">
  206. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  207. </a></li>
  208. </ul>
  209. </blockquote>
  210. </td></tr>
  211. </table>
  212. </blockquote>
  213. </td></tr>
  214. </table>
  215. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  216. <tr><td bgcolor="#525D76">
  217. <font color="#ffffff" face="arial,helvetica,sanserif">
  218. <strong>Answers</strong>
  219. </font>
  220. </td></tr>
  221. <tr><td>
  222. <blockquote>
  223. <a name="what-is-ant">
  224. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  225. <tr><td bgcolor="#828DA6">
  226. <font color="#ffffff" face="arial,helvetica,sanserif">
  227. <strong>
  228. What is Ant?
  229. </strong>
  230. </font>
  231. </td></tr>
  232. <tr><td>
  233. <blockquote>
  234. <p> Ant is a Java based build tool. In theory it is kind of
  235. like "make" without makes wrinkles and with the full
  236. portability of pure Java code.</p>
  237. </blockquote>
  238. </td></tr>
  239. </table>
  240. </a>
  241. <a name="ant-name">
  242. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  243. <tr><td bgcolor="#828DA6">
  244. <font color="#ffffff" face="arial,helvetica,sanserif">
  245. <strong>
  246. Why do you call it Ant?
  247. </strong>
  248. </font>
  249. </td></tr>
  250. <tr><td>
  251. <blockquote>
  252. <p>According to Ant's original author James Duncan
  253. Davidson, the name is an acronym for "Another Neat
  254. Tool".</p>
  255. <p>Later explanations go along the lines of "Ants are
  256. doing an extremely good job at building things" or
  257. "Ants are very small and can carry a weight a dozen times
  258. of their own" - describing what Ant is intended to
  259. be.</p>
  260. </blockquote>
  261. </td></tr>
  262. </table>
  263. </a>
  264. <a name="history">
  265. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  266. <tr><td bgcolor="#828DA6">
  267. <font color="#ffffff" face="arial,helvetica,sanserif">
  268. <strong>
  269. Tell us a little bit about Ant's history.
  270. </strong>
  271. </font>
  272. </td></tr>
  273. <tr><td>
  274. <blockquote>
  275. <p>Initially Ant was part of the Tomcat code base when it was
  276. donated to the Apache Software Foundation - it has been
  277. created by James Duncan Davidson, who also is the original
  278. author of Tomcat. Ant was there to build Tomcat, nothing
  279. else.</p>
  280. <p>Soon thereafter several open source Java projects realized
  281. that Ant could solve the problems they had with makefiles.
  282. Starting with the projects hosted at Jakarta and the old Java
  283. Apache project, Ant spread like a virus and now is the build
  284. tool of choice for a lot of projects.</p>
  285. <p>In January 2000 Ant was moved to a separate CVS module and
  286. was promoted to a project of its own, independent of
  287. Tomcat.</p>
  288. <p>The first version of Ant that was exposed a lager audience
  289. was the one that shipped with Tomcat's 3.1 release on 19 April
  290. 2000. This version has later been referenced to as Ant
  291. 0.3.1.</p>
  292. <p>The first official release of Ant as a stand alone product was
  293. Ant 1.1 released on 19 July 2000. The complete release
  294. history:</p>
  295. <table>
  296. <tr>
  297. <td bgcolor="#039acc" colspan="" rowspan=""
  298. valign="top" align="left">
  299. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  300. Ant Version
  301. </font>
  302. </td>
  303. <td bgcolor="#039acc" colspan="" rowspan=""
  304. valign="top" align="left">
  305. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  306. Release Date
  307. </font>
  308. </td>
  309. </tr>
  310. <tr>
  311. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  312. valign="top" align="left">
  313. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  314. 1.1
  315. </font>
  316. </td>
  317. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  318. valign="top" align="left">
  319. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  320. 19 July 2000
  321. </font>
  322. </td>
  323. </tr>
  324. <tr>
  325. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  326. valign="top" align="left">
  327. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  328. 1.2
  329. </font>
  330. </td>
  331. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  332. valign="top" align="left">
  333. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  334. 24 October 2000
  335. </font>
  336. </td>
  337. </tr>
  338. <tr>
  339. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  340. valign="top" align="left">
  341. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  342. 1.3
  343. </font>
  344. </td>
  345. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  346. valign="top" align="left">
  347. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  348. 3 March 2001
  349. </font>
  350. </td>
  351. </tr>
  352. </table>
  353. </blockquote>
  354. </td></tr>
  355. </table>
  356. </a>
  357. <a name="no-gnu-tar">
  358. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  359. <tr><td bgcolor="#828DA6">
  360. <font color="#ffffff" face="arial,helvetica,sanserif">
  361. <strong>
  362. I get checksum errors when I try to extract the
  363. <code>tar.gz</code> distribution file. Why?
  364. </strong>
  365. </font>
  366. </td></tr>
  367. <tr><td>
  368. <blockquote>
  369. <p>Ant's distribution contains file names that are longer
  370. than 100 characters, which is not supported by the standard
  371. tar file format. Several different implementations of tar use
  372. different and incompatible ways to work around this
  373. restriction.</p>
  374. <p>Ant's &lt;tar&gt; task can create tar archives that use
  375. the GNU tar extension, and this has been used when putting
  376. together the distribution. If you are using a different
  377. version of tar (for example, the one shipping with Solaris),
  378. you cannot use it to extract the archive.</p>
  379. <p>The solution is to either install GNU tar, which can be
  380. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
  381. or use the zip archive instead (you can extract it using
  382. <code>jar xf</code>).</p>
  383. </blockquote>
  384. </td></tr>
  385. </table>
  386. </a>
  387. <a name="always-recompiles">
  388. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  389. <tr><td bgcolor="#828DA6">
  390. <font color="#ffffff" face="arial,helvetica,sanserif">
  391. <strong>
  392. Why does Ant always recompile all my Java files?
  393. </strong>
  394. </font>
  395. </td></tr>
  396. <tr><td>
  397. <blockquote>
  398. <p>In order to find out which files should be compiled, Ant
  399. compares the timestamps of the source files to those of the
  400. resulting <code>.class</code> files. Opening all source files
  401. to find out which package they belong to would be very
  402. inefficient - instead of this, Ant expects you to place your
  403. source files in a directory hierarchy that mirrors your
  404. package hierarchy and to point Ant to the root of this
  405. directory tree with the <code>srcdir</code> attribute.</p>
  406. <p>Say you have <code>&lt;javac srcdir="src"
  407. destdir="dest" /&gt;</code>. If Ant finds a file
  408. <code>src/a/b/C.java</code> it expects it to be in package
  409. <code>a.b</code> so that the resulting <code>.class</code>
  410. file is going to be <code>dest/a/b/C.class</code>.</p>
  411. <p>If your setup is different, Ant's heuristic won't work and
  412. it will recompile classes that are up to date. Ant is not the
  413. only tool, that expects a source tree layout like this.</p>
  414. </blockquote>
  415. </td></tr>
  416. </table>
  417. </a>
  418. <a name="passing-cli-args">
  419. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  420. <tr><td bgcolor="#828DA6">
  421. <font color="#ffffff" face="arial,helvetica,sanserif">
  422. <strong>
  423. How do I pass parameters from the command line to my
  424. build file?
  425. </strong>
  426. </font>
  427. </td></tr>
  428. <tr><td>
  429. <blockquote>
  430. <p>Use properties: <code>ant
  431. -D&lt;name&gt;=&lt;value&gt;</code> lets you define values for
  432. properties. These can then be used within your build file as
  433. any normal property: <code>${&lt;name&gt;}</code> will put in
  434. <code>&lt;value&gt;</code>.</p>
  435. </blockquote>
  436. </td></tr>
  437. </table>
  438. </a>
  439. <a name="jikes-switches">
  440. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  441. <tr><td bgcolor="#828DA6">
  442. <font color="#ffffff" face="arial,helvetica,sanserif">
  443. <strong>
  444. How can I use Jikes specific command line
  445. switches?
  446. </strong>
  447. </font>
  448. </td></tr>
  449. <tr><td>
  450. <blockquote>
  451. <p>A couple of switches are supported via magic
  452. properties:</p>
  453. <table>
  454. <tr>
  455. <td bgcolor="#039acc" colspan="" rowspan=""
  456. valign="top" align="left">
  457. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  458. switch
  459. </font>
  460. </td>
  461. <td bgcolor="#039acc" colspan="" rowspan=""
  462. valign="top" align="left">
  463. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  464. property
  465. </font>
  466. </td>
  467. <td bgcolor="#039acc" colspan="" rowspan=""
  468. valign="top" align="left">
  469. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  470. default
  471. </font>
  472. </td>
  473. </tr>
  474. <tr>
  475. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  476. valign="top" align="left">
  477. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  478. +E
  479. </font>
  480. </td>
  481. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  482. valign="top" align="left">
  483. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  484. build.compiler.emacs
  485. </font>
  486. </td>
  487. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  488. valign="top" align="left">
  489. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  490. false == not set
  491. </font>
  492. </td>
  493. </tr>
  494. <tr>
  495. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  496. valign="top" align="left">
  497. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  498. -nowarn
  499. </font>
  500. </td>
  501. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  502. valign="top" align="left">
  503. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  504. build.compiler.warnings
  505. </font>
  506. </td>
  507. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  508. valign="top" align="left">
  509. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  510. true == not set
  511. </font>
  512. </td>
  513. </tr>
  514. <tr>
  515. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  516. valign="top" align="left">
  517. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  518. +P
  519. </font>
  520. </td>
  521. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  522. valign="top" align="left">
  523. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  524. build.compiler.pedantic
  525. </font>
  526. </td>
  527. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  528. valign="top" align="left">
  529. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  530. false == not set
  531. </font>
  532. </td>
  533. </tr>
  534. <tr>
  535. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  536. valign="top" align="left">
  537. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  538. +F
  539. </font>
  540. </td>
  541. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  542. valign="top" align="left">
  543. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  544. build.compiler.fulldepend
  545. </font>
  546. </td>
  547. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  548. valign="top" align="left">
  549. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  550. false == not set
  551. </font>
  552. </td>
  553. </tr>
  554. </table>
  555. </blockquote>
  556. </td></tr>
  557. </table>
  558. </a>
  559. <a name="integration">
  560. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  561. <tr><td bgcolor="#828DA6">
  562. <font color="#ffffff" face="arial,helvetica,sanserif">
  563. <strong>
  564. Is Ant supported by my IDE/Editor?
  565. </strong>
  566. </font>
  567. </td></tr>
  568. <tr><td>
  569. <blockquote>
  570. <p>See the <a href="external.html#IDE%47Editor+Integration">section
  571. on IDE integration</a> on our external tools page.</p>
  572. </blockquote>
  573. </td></tr>
  574. </table>
  575. </a>
  576. <a name="emacs-mode">
  577. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  578. <tr><td bgcolor="#828DA6">
  579. <font color="#ffffff" face="arial,helvetica,sanserif">
  580. <strong>
  581. Why doesn't (X)Emacs parse the error messages generated
  582. by Ant correctly?
  583. </strong>
  584. </font>
  585. </td></tr>
  586. <tr><td>
  587. <blockquote>
  588. <p>Ant adds a "banner" with the name of the current
  589. task in front of all messages - and there are no built-in
  590. regular expressions in Emacs that would account for this.</p>
  591. <p>You can disable this banner by invoking Ant with the
  592. <code>-emacs</code> switch. Alternatively you can add the
  593. following snippet to your <code>.emacs</code> to make Emacs
  594. understand Ant's output.</p>
  595. <div align="left">
  596. <table cellspacing="4" cellpadding="0" border="0">
  597. <tr>
  598. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  599. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  600. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  601. </tr>
  602. <tr>
  603. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  604. <td bgcolor="#ffffff"><pre>
  605. (require 'compile)
  606. (setq compilation-error-regexp-alist
  607. (append (list
  608. ;; works for jikes
  609. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  610. ;; works for javac
  611. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  612. compilation-error-regexp-alist))
  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. </blockquote>
  624. </td></tr>
  625. </table>
  626. </a>
  627. <a name="dtd">
  628. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  629. <tr><td bgcolor="#828DA6">
  630. <font color="#ffffff" face="arial,helvetica,sanserif">
  631. <strong>
  632. Is there a DTD that I can use to validate my build
  633. files?
  634. </strong>
  635. </font>
  636. </td></tr>
  637. <tr><td>
  638. <blockquote>
  639. <p>An incomplete DTD can be created by the
  640. <code>&lt;antstructure&gt;</code> task - but this one
  641. has a few problems:</p>
  642. <ul>
  643. <li>It doesn't know about required attributes. Only
  644. manual tweaking of this file can help here.</li>
  645. <li>It is not complete - if you add new tasks via
  646. <code>&lt;taskdef&gt;</code> it won't know about it. See
  647. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  648. page</a> by Michel Casabianca for a solution to this
  649. problem. Note that the DTD you can download at this page
  650. is based on Ant 0.3.1.</li>
  651. <li>It may even be an invalid DTD. As Ant allows tasks
  652. writers to define arbitrary elements, name collisions will
  653. happen quite frequently - if your version of Ant contains
  654. the optional <code>&lt;test&gt;</code> and
  655. <code>&lt;junit&gt;</code> tasks, there are two XML
  656. elements named test (the task and the nested child element
  657. of <code>&lt;junit&gt;</code>) with different attribute
  658. lists. This problem cannot be solved, DTDs don't give a
  659. syntax rich enough to support this.</li>
  660. </ul>
  661. </blockquote>
  662. </td></tr>
  663. </table>
  664. </a>
  665. <a name="xml-entity-include">
  666. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  667. <tr><td bgcolor="#828DA6">
  668. <font color="#ffffff" face="arial,helvetica,sanserif">
  669. <strong>
  670. How do I include an XML snippet in my build file?
  671. </strong>
  672. </font>
  673. </td></tr>
  674. <tr><td>
  675. <blockquote>
  676. <p>You can use XML's way of including external files and let
  677. the parser do the job for Ant:</p>
  678. <div align="left">
  679. <table cellspacing="4" cellpadding="0" border="0">
  680. <tr>
  681. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  682. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  683. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  684. </tr>
  685. <tr>
  686. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  687. <td bgcolor="#ffffff"><pre>
  688. &lt;?xml version=&quot;1.0&quot;?&gt;
  689. &lt;!DOCTYPE project [
  690. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  691. ]&gt;
  692. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  693. &lt;target name=&quot;setup&quot;&gt;
  694. ...
  695. &lt;/target&gt;
  696. &amp;common;
  697. ...
  698. &lt;/project&gt;
  699. </pre></td>
  700. <td bgcolor="#023264" width="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" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  704. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  705. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  706. </tr>
  707. </table>
  708. </div>
  709. <p>will literally include the contents of <code>common.xml</code> where
  710. you've placed the <code>&amp;common;</code> entity.</p>
  711. <p>In combination with a DTD, this would look like this:</p>
  712. <div align="left">
  713. <table cellspacing="4" cellpadding="0" border="0">
  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. <tr>
  720. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  721. <td bgcolor="#ffffff"><pre>
  722. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  723. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  724. ]&gt;
  725. </pre></td>
  726. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  727. </tr>
  728. <tr>
  729. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  730. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  731. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  732. </tr>
  733. </table>
  734. </div>
  735. </blockquote>
  736. </td></tr>
  737. </table>
  738. </a>
  739. <a name="mail-logger">
  740. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  741. <tr><td bgcolor="#828DA6">
  742. <font color="#ffffff" face="arial,helvetica,sanserif">
  743. <strong>
  744. How do I send an email with the result of my build
  745. process?
  746. </strong>
  747. </font>
  748. </td></tr>
  749. <tr><td>
  750. <blockquote>
  751. <p>You can use a custom BuildListener, that sends out an email
  752. in the buildFinished() method. Will Glozer
  753. &lt;will.glozer@jda.com&gt; has written such a listener based
  754. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>,
  755. the source is</p>
  756. <div align="left">
  757. <table cellspacing="4" cellpadding="0" border="0">
  758. <tr>
  759. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  760. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  761. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  762. </tr>
  763. <tr>
  764. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  765. <td bgcolor="#ffffff"><pre>
  766. import java.io.*;
  767. import java.util.*;
  768. import javax.mail.*;
  769. import javax.mail.internet.*;
  770. import org.apache.tools.ant.*;
  771. /**
  772. * A simple listener that waits for a build to finish and sends an email
  773. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  774. * are fairly self explanatory.
  775. *
  776. * @author Will Glozer
  777. * @version 1.05a 09/06/2000
  778. */
  779. public class BuildMonitor implements BuildListener {
  780. protected Properties props;
  781. /**
  782. * Create a new BuildMonitor.
  783. */
  784. public BuildMonitor() throws Exception {
  785. props = new Properties();
  786. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  787. props.load(is);
  788. is.close();
  789. }
  790. public void buildStarted(BuildEvent e) {
  791. }
  792. /**
  793. * Determine the status of the build and the actions to follow, now that
  794. * the build has completed.
  795. *
  796. * @param e Event describing the build tatus.
  797. */
  798. public void buildFinished(BuildEvent e) {
  799. Throwable th = e.getException();
  800. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  801. try {
  802. String key = &quot;build.&quot; + status;
  803. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  804. return;
  805. }
  806. Session session = Session.getDefaultInstance(props, null);
  807. MimeMessage message = new MimeMessage(session);
  808. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  809. props.getProperty(key + &quot;.email.to&quot;)));
  810. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  811. BufferedReader br = new BufferedReader(new FileReader(
  812. props.getProperty(&quot;build.log&quot;)));
  813. StringWriter sw = new StringWriter();
  814. String line = br.readLine();
  815. while (line != null) {
  816. sw.write(line);
  817. sw.write(&quot;\n&quot;);
  818. line = br.readLine();
  819. }
  820. br.close();
  821. message.setText(sw.toString(), &quot;UTF-8&quot;);
  822. sw.close();
  823. Transport transport = session.getTransport();
  824. transport.connect();
  825. transport.send(message);
  826. transport.close();
  827. } catch (Exception ex) {
  828. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  829. ex.printStackTrace();
  830. }
  831. }
  832. /**
  833. * Parse a comma separated list of internet email addresses.
  834. *
  835. * @param s The list of addresses.
  836. * @return Array of Addresses.
  837. */
  838. protected Address[] parseAddresses(String s) throws Exception {
  839. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  840. Address[] addrs = new Address[st.countTokens()];
  841. for (int i = 0; i &lt; addrs.length; i++) {
  842. addrs[i] = new InternetAddress(st.nextToken());
  843. }
  844. return addrs;
  845. }
  846. public void messageLogged(BuildEvent e) {
  847. }
  848. public void targetStarted(BuildEvent e) {
  849. }
  850. public void targetFinished(BuildEvent e) {
  851. }
  852. public void taskStarted(BuildEvent e) {
  853. }
  854. public void taskFinished(BuildEvent e) {
  855. }
  856. }
  857. </pre></td>
  858. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  859. </tr>
  860. <tr>
  861. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  862. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  863. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  864. </tr>
  865. </table>
  866. </div>
  867. <p>With a <code>monitor.properties</code> like this</p>
  868. <div align="left">
  869. <table cellspacing="4" cellpadding="0" border="0">
  870. <tr>
  871. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  872. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  873. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  874. </tr>
  875. <tr>
  876. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  877. <td bgcolor="#ffffff"><pre>
  878. # configuration for build monitor
  879. mail.transport.protocol=smtp
  880. mail.smtp.host=&lt;host&gt;
  881. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  882. build.log=build.log
  883. build.failed.notify=true
  884. build.failed.email.to=will.glozer@jda.com
  885. build.failed.email.subject=Nightly build failed!
  886. build.succeeded.notify=true
  887. build.succeeded.email.to=will.glozer@jda.com
  888. build.succeeded.email.subject=Nightly build succeeded!
  889. </pre></td>
  890. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  891. </tr>
  892. <tr>
  893. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  894. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  895. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  896. </tr>
  897. </table>
  898. </div>
  899. <p><code>monitor.properties</code> should be placed right next
  900. to your compiled <code>BuildMonitor.class</code>. To use it,
  901. invoke Ant like</p>
  902. <div align="left">
  903. <table cellspacing="4" cellpadding="0" border="0">
  904. <tr>
  905. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  906. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  907. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  908. </tr>
  909. <tr>
  910. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  911. <td bgcolor="#ffffff"><pre>
  912. ant -listener BuildMonitor
  913. </pre></td>
  914. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  915. </tr>
  916. <tr>
  917. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  918. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  919. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  920. </tr>
  921. </table>
  922. </div>
  923. <p>Make sure that <code>mail.jar</code> from JavaMail and
  924. <code>activation.jar</code> from the
  925. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  926. Beans Activation Framework</a> in your <code>CLASSPATH</code>.</p>
  927. </blockquote>
  928. </td></tr>
  929. </table>
  930. </a>
  931. <a name="remove-cr">
  932. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  933. <tr><td bgcolor="#828DA6">
  934. <font color="#ffffff" face="arial,helvetica,sanserif">
  935. <strong>
  936. &lt;chmod&gt; or &lt;exec&gt; don't work in Ant
  937. 1.3 on Unix
  938. </strong>
  939. </font>
  940. </td></tr>
  941. <tr><td>
  942. <blockquote>
  943. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  944. has DOS instead of Unix line endings, you must remove the
  945. carriage return characters from this file. This can be done by
  946. using Ant's &lt;fixcrlf&gt; task or something like:</p>
  947. <div align="left">
  948. <table cellspacing="4" cellpadding="0" border="0">
  949. <tr>
  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. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  952. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  953. </tr>
  954. <tr>
  955. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  956. <td bgcolor="#ffffff"><pre>
  957. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  958. mv /tmp/foo $ANT_HOME/bin/antRun
  959. </pre></td>
  960. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  961. </tr>
  962. <tr>
  963. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  964. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  965. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  966. </tr>
  967. </table>
  968. </div>
  969. </blockquote>
  970. </td></tr>
  971. </table>
  972. </a>
  973. <a name="javadoc-cannot-execute">
  974. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  975. <tr><td bgcolor="#828DA6">
  976. <font color="#ffffff" face="arial,helvetica,sanserif">
  977. <strong>
  978. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  979. </strong>
  980. </font>
  981. </td></tr>
  982. <tr><td>
  983. <blockquote>
  984. <p>There is a bug in the Solaris reference implementation of
  985. 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>.
  986. This also appears to be true under Linux, moving the JDK to
  987. the front of the PATH fixes the problem.</p>
  988. </blockquote>
  989. </td></tr>
  990. </table>
  991. </a>
  992. </blockquote>
  993. </td></tr>
  994. </table>
  995. </td>
  996. </tr>
  997. <!-- FOOTER -->
  998. <tr><td colspan="2">
  999. <hr noshade="" size="1"/>
  1000. </td></tr>
  1001. <tr><td colspan="2">
  1002. <div align="center"><font color="#525D76" size="-1"><em>
  1003. Copyright &#169; 1999-2001, Apache Software Foundation
  1004. </em></font></div>
  1005. </td></tr>
  1006. </table>
  1007. </body>
  1008. </html>
  1009. <!-- end the processing -->