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

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