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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848
  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. <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  8. <meta name="author" value="Stefan Bodewig">
  9. <meta name="email" value="bodewig@apache.org">
  10. <title>Apache Ant - Frequently Asked Questions</title>
  11. </head>
  12. <body bgcolor="#ffffff" text="#000000" link="#525D76">
  13. <table border="0" width="100%" cellspacing="0">
  14. <!-- TOP IMAGE -->
  15. <tr>
  16. <td align="left">
  17. <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" border="0"/></a>
  18. </td>
  19. <td align="center">
  20. <a href="http://www.javaworld.com"><img src="images/jw_ec_logo_finalist2002.gif" border="0"/></a>
  21. </td>
  22. <td align="right">
  23. <a href="http://jakarta.apache.org/ant/"><img src="./artwork/ant_logo_large.gif" alt="Apache Ant" border="0"/></a>
  24. </td>
  25. </tr>
  26. </table>
  27. <table border="0" width="100%" cellspacing="4">
  28. <tr><td colspan="2">
  29. <hr noshade="" size="1"/>
  30. </td></tr>
  31. <tr>
  32. <!-- LEFT SIDE NAVIGATION -->
  33. <td valign="top" nowrap="true">
  34. <p><strong>Apache Ant</strong></p>
  35. <ul>
  36. <li> <a href="./index.html">Front Page</a>
  37. </li>
  38. <li> <a href="./antnews.html">News</a>
  39. </li>
  40. <li> <a href="./manual/index.html">Documentation</a>
  41. </li>
  42. <li> <a href="./projects.html">Related Projects</a>
  43. </li>
  44. <li> <a href="./external.html">External Tools and Tasks</a>
  45. </li>
  46. <li> <a href="./resources.html">Resources</a>
  47. </li>
  48. <li> <a href="./faq.html">Ant FAQ</a>
  49. </li>
  50. <li> <a href="./problems.html">Having Problems?</a>
  51. </li>
  52. </ul>
  53. <p><strong>Download</strong></p>
  54. <ul>
  55. <li> <a href="http://jakarta.apache.org/site/binindex.html">Binaries</a>
  56. </li>
  57. <li> <a href="http://jakarta.apache.org/site/sourceindex.html">Source Code</a>
  58. </li>
  59. </ul>
  60. <p><strong>Jakarta</strong></p>
  61. <ul>
  62. <li> <a href="http://jakarta.apache.org/site/news.html">News & Status</a>
  63. </li>
  64. <li> <a href="http://jakarta.apache.org/site/mission.html">Mission</a>
  65. </li>
  66. <li> <a href="http://jakarta.apache.org/site/guidelines.html">Guidelines Notes</a>
  67. </li>
  68. <li> <a href="http://jakarta.apache.org/site/faqs.html">FAQs</a>
  69. </li>
  70. </ul>
  71. <p><strong>Get Involved</strong></p>
  72. <ul>
  73. <li> <a href="http://jakarta.apache.org/site/getinvolved.html">Overview</a>
  74. </li>
  75. <li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a>
  76. </li>
  77. <li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
  78. </li>
  79. <li> <a href="http://jakarta.apache.org/site/library.html">Reference Library</a>
  80. </li>
  81. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant">Bug Database</a>
  82. </li>
  83. <li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant&bug_severity=Enhancement">Enhancement Requests</a>
  84. </li>
  85. </ul>
  86. </td>
  87. <td align="left" valign="top">
  88. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  89. <tr><td bgcolor="#525D76">
  90. <font color="#ffffff" face="arial,helvetica,sanserif">
  91. <strong>Questions</strong>
  92. </font>
  93. </td></tr>
  94. <tr><td>
  95. <blockquote>
  96. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  97. <tr><td bgcolor="#828DA6">
  98. <font color="#ffffff" face="arial,helvetica,sanserif">
  99. <strong>About this FAQ</strong>
  100. </font>
  101. </td></tr>
  102. <tr><td>
  103. <blockquote>
  104. <ul>
  105. <li><a href="#latest-version">
  106. Where do I find the latest version of this
  107. document?
  108. </a></li>
  109. <li><a href="#adding-faqs">
  110. How can I contribute to this FAQ?
  111. </a></li>
  112. <li><a href="#creating-faq">
  113. How do you create the HTML version of this
  114. FAQ?
  115. </a></li>
  116. </ul>
  117. </blockquote>
  118. </td></tr>
  119. </table>
  120. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  121. <tr><td bgcolor="#828DA6">
  122. <font color="#ffffff" face="arial,helvetica,sanserif">
  123. <strong>General</strong>
  124. </font>
  125. </td></tr>
  126. <tr><td>
  127. <blockquote>
  128. <ul>
  129. <li><a href="#what-is-ant">
  130. What is Apache Ant?
  131. </a></li>
  132. <li><a href="#ant-name">
  133. Why do you call it Ant?
  134. </a></li>
  135. <li><a href="#history">
  136. Tell us a little bit about Ant's history.
  137. </a></li>
  138. </ul>
  139. </blockquote>
  140. </td></tr>
  141. </table>
  142. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  143. <tr><td bgcolor="#828DA6">
  144. <font color="#ffffff" face="arial,helvetica,sanserif">
  145. <strong>Installation</strong>
  146. </font>
  147. </td></tr>
  148. <tr><td>
  149. <blockquote>
  150. <ul>
  151. <li><a href="#no-gnu-tar">
  152. I get checksum errors when I try to extract the
  153. <code>tar.gz</code> distribution file. Why?
  154. </a></li>
  155. </ul>
  156. </blockquote>
  157. </td></tr>
  158. </table>
  159. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  160. <tr><td bgcolor="#828DA6">
  161. <font color="#ffffff" face="arial,helvetica,sanserif">
  162. <strong>Using Ant</strong>
  163. </font>
  164. </td></tr>
  165. <tr><td>
  166. <blockquote>
  167. <ul>
  168. <li><a href="#always-recompiles">
  169. Why does Ant always recompile all my Java files?
  170. </a></li>
  171. <li><a href="#passing-cli-args">
  172. How do I pass parameters from the command line to my
  173. build file?
  174. </a></li>
  175. <li><a href="#jikes-switches">
  176. How can I use Jikes-specific command-line
  177. switches?
  178. </a></li>
  179. <li><a href="#shell-redirect-1">
  180. How do I include a &lt; character in my command-line arguments?
  181. </a></li>
  182. <li><a href="#shell-redirect-2">
  183. How do I redirect standard input or standard output
  184. in the <code>&lt;exec&gt;</code> task?
  185. </a></li>
  186. <li><a href="#batch-shell-execute">
  187. How do I execute a batch file or shell script from Ant?
  188. </a></li>
  189. <li><a href="#defaultexcludes">
  190. I've used a <code>&lt;delete&gt;</code> task to delete
  191. unwanted
  192. SourceSafe control files (CVS files, editor backup files, etc.), but
  193. it doesn't seem to work; the files never get deleted. What's
  194. wrong?
  195. </a></li>
  196. <li><a href="#multi-conditions">
  197. I want to execute a particular target only if
  198. multiple conditions are true.
  199. </a></li>
  200. <li><a href="#stop-dependency">
  201. I have a target I want to skip if a property is set,
  202. so I have <code>unless="property"</code> as an attribute
  203. of the target, but all the targets this target
  204. depends on are still executed. Why?
  205. </a></li>
  206. <li><a href="#include-order">
  207. In my <code>&lt;fileset&gt;</code>, I've put in an
  208. <code>&lt;exclude&gt;</code> of all files followed by an
  209. <code>&lt;include&gt;</code> of just the files I want, but it
  210. isn't giving me any files at all. What's wrong?
  211. </a></li>
  212. </ul>
  213. </blockquote>
  214. </td></tr>
  215. </table>
  216. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  217. <tr><td bgcolor="#828DA6">
  218. <font color="#ffffff" face="arial,helvetica,sanserif">
  219. <strong>Ant and IDEs/Editors</strong>
  220. </font>
  221. </td></tr>
  222. <tr><td>
  223. <blockquote>
  224. <ul>
  225. <li><a href="#integration">
  226. Is Ant supported by my IDE/Editor?
  227. </a></li>
  228. <li><a href="#emacs-mode">
  229. Why doesn't (X)Emacs/vi/MacOS X's project builder
  230. correctly parse the error messages generated by Ant?
  231. </a></li>
  232. </ul>
  233. </blockquote>
  234. </td></tr>
  235. </table>
  236. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  237. <tr><td bgcolor="#828DA6">
  238. <font color="#ffffff" face="arial,helvetica,sanserif">
  239. <strong>Advanced Issues</strong>
  240. </font>
  241. </td></tr>
  242. <tr><td>
  243. <blockquote>
  244. <ul>
  245. <li><a href="#dtd">
  246. Is there a DTD that I can use to validate my build
  247. files?
  248. </a></li>
  249. <li><a href="#xml-entity-include">
  250. How do I include an XML snippet in my build file?
  251. </a></li>
  252. <li><a href="#mail-logger">
  253. How do I send an email with the result of my build
  254. process?
  255. </a></li>
  256. <li><a href="#listener-properties">
  257. How do I get at the properties that Ant was running
  258. with from inside BuildListener?
  259. </a></li>
  260. </ul>
  261. </blockquote>
  262. </td></tr>
  263. </table>
  264. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  265. <tr><td bgcolor="#828DA6">
  266. <font color="#ffffff" face="arial,helvetica,sanserif">
  267. <strong>Known Problems</strong>
  268. </font>
  269. </td></tr>
  270. <tr><td>
  271. <blockquote>
  272. <ul>
  273. <li><a href="#remove-cr">
  274. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  275. 1.3 on Unix
  276. </a></li>
  277. <li><a href="#javadoc-cannot-execute">
  278. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  279. </a></li>
  280. </ul>
  281. </blockquote>
  282. </td></tr>
  283. </table>
  284. </blockquote>
  285. </td></tr>
  286. </table>
  287. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  288. <tr><td bgcolor="#525D76">
  289. <font color="#ffffff" face="arial,helvetica,sanserif">
  290. <strong>Answers</strong>
  291. </font>
  292. </td></tr>
  293. <tr><td>
  294. <blockquote>
  295. <a name="latest-version">
  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. Where do I find the latest version of this
  301. document?
  302. </strong>
  303. </font>
  304. </td></tr>
  305. <tr><td>
  306. <blockquote>
  307. <p>The latest version can always be found at Ant's homepage
  308. <a href="http://jakarta.apache.org/ant/faq.html">http://jakarta.apache.org/ant/faq.html</a>.</p>
  309. </blockquote>
  310. </td></tr>
  311. </table>
  312. </a>
  313. <a name="adding-faqs">
  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. How can I contribute to this FAQ?
  319. </strong>
  320. </font>
  321. </td></tr>
  322. <tr><td>
  323. <blockquote>
  324. <p>The page you are looking it is generated from
  325. <a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/jakarta-ant/xdocs/faq.xml">this</a>
  326. document. If you want to add a new question, please submit
  327. a patch against this document to one of Ant's mailing lists;
  328. hopefully, the structure is self-explanatory.</p>
  329. <p>If you don't know how to create a patch, see the patches
  330. section of <a href="http://jakarta.apache.org/site/source.html">this
  331. page</a>.</p>
  332. </blockquote>
  333. </td></tr>
  334. </table>
  335. </a>
  336. <a name="creating-faq">
  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. How do you create the HTML version of this
  342. FAQ?
  343. </strong>
  344. </font>
  345. </td></tr>
  346. <tr><td>
  347. <blockquote>
  348. <p>We use
  349. <a href="http://jakarta.apache.org/velocity/anakia.html">Anakia</a>
  350. to render the HTML version from the original XML file.</p>
  351. <p>The Velocity stylesheets used to process the XML files can
  352. be found in the <code>xdocs/stylesheets</code> subdirectory of
  353. Ant's CVS repository - the build file <code>docs.xml</code> is
  354. used to drive Anakia. This file assumes that you have the
  355. <code>jakarta-site2</code> module checked out from CVS as
  356. well, but if you follow the instruction from Anakia's
  357. homepage, you should get it to work without that. Just make
  358. sure all required jars are in the task's classpath.</p>
  359. </blockquote>
  360. </td></tr>
  361. </table>
  362. </a>
  363. <a name="what-is-ant">
  364. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  365. <tr><td bgcolor="#828DA6">
  366. <font color="#ffffff" face="arial,helvetica,sanserif">
  367. <strong>
  368. What is Apache Ant?
  369. </strong>
  370. </font>
  371. </td></tr>
  372. <tr><td>
  373. <blockquote>
  374. <p> Ant is a Java-based build tool. In theory, it is kind of
  375. like Make, without Make's wrinkles and with the full
  376. portability of pure Java code.</p>
  377. </blockquote>
  378. </td></tr>
  379. </table>
  380. </a>
  381. <a name="ant-name">
  382. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  383. <tr><td bgcolor="#828DA6">
  384. <font color="#ffffff" face="arial,helvetica,sanserif">
  385. <strong>
  386. Why do you call it Ant?
  387. </strong>
  388. </font>
  389. </td></tr>
  390. <tr><td>
  391. <blockquote>
  392. <p>According to Ant's original author, James Duncan
  393. Davidson, the name is an acronym for "Another Neat
  394. Tool".</p>
  395. <p>Later explanations go along the lines of "ants
  396. do an extremely good job at building things", or
  397. "ants are very small and can carry a weight dozens of times
  398. their own" - describing what Ant is intended to
  399. be.</p>
  400. </blockquote>
  401. </td></tr>
  402. </table>
  403. </a>
  404. <a name="history">
  405. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  406. <tr><td bgcolor="#828DA6">
  407. <font color="#ffffff" face="arial,helvetica,sanserif">
  408. <strong>
  409. Tell us a little bit about Ant's history.
  410. </strong>
  411. </font>
  412. </td></tr>
  413. <tr><td>
  414. <blockquote>
  415. <p>Initially, Ant was part of the Tomcat code base, when it was
  416. donated to the Apache Software Foundation. It was
  417. created by James Duncan Davidson, who is also the original
  418. author of Tomcat. Ant was there to build Tomcat, nothing
  419. else.</p>
  420. <p>Soon thereafter, several open source Java projects realized
  421. that Ant could solve the problems they had with Makefiles.
  422. Starting with the projects hosted at Jakarta and the old Java
  423. Apache project, Ant spread like a virus and is now the build
  424. tool of choice for a lot of projects.</p>
  425. <p>In January 2000, Ant was moved to a separate CVS module and
  426. was promoted to a project of its own, independent of
  427. Tomcat, and became Apache Ant.</p>
  428. <p>The first version of Ant that was exposed to a larger audience
  429. was the one that shipped with Tomcat's 3.1 release on 19 April
  430. 2000. This version has later been referred to as Ant
  431. 0.3.1.</p>
  432. <p>The first official release of Ant as a stand-alone product was
  433. Ant 1.1, released on 19 July 2000. The complete release
  434. history:</p>
  435. <table>
  436. <tr>
  437. <td bgcolor="#039acc" colspan="" rowspan=""
  438. valign="top" align="left">
  439. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  440. Ant Version
  441. </font>
  442. </td>
  443. <td bgcolor="#039acc" colspan="" rowspan=""
  444. valign="top" align="left">
  445. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  446. Release Date
  447. </font>
  448. </td>
  449. </tr>
  450. <tr>
  451. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  452. valign="top" align="left">
  453. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  454. 1.1
  455. </font>
  456. </td>
  457. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  458. valign="top" align="left">
  459. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  460. 19 July 2000
  461. </font>
  462. </td>
  463. </tr>
  464. <tr>
  465. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  466. valign="top" align="left">
  467. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  468. 1.2
  469. </font>
  470. </td>
  471. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  472. valign="top" align="left">
  473. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  474. 24 October 2000
  475. </font>
  476. </td>
  477. </tr>
  478. <tr>
  479. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  480. valign="top" align="left">
  481. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  482. 1.3
  483. </font>
  484. </td>
  485. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  486. valign="top" align="left">
  487. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  488. 3 March 2001
  489. </font>
  490. </td>
  491. </tr>
  492. <tr>
  493. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  494. valign="top" align="left">
  495. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  496. 1.4
  497. </font>
  498. </td>
  499. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  500. valign="top" align="left">
  501. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  502. 3 September 2001
  503. </font>
  504. </td>
  505. </tr>
  506. <tr>
  507. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  508. valign="top" align="left">
  509. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  510. 1.4.1
  511. </font>
  512. </td>
  513. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  514. valign="top" align="left">
  515. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  516. 11 October 2001
  517. </font>
  518. </td>
  519. </tr>
  520. </table>
  521. </blockquote>
  522. </td></tr>
  523. </table>
  524. </a>
  525. <a name="no-gnu-tar">
  526. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  527. <tr><td bgcolor="#828DA6">
  528. <font color="#ffffff" face="arial,helvetica,sanserif">
  529. <strong>
  530. I get checksum errors when I try to extract the
  531. <code>tar.gz</code> distribution file. Why?
  532. </strong>
  533. </font>
  534. </td></tr>
  535. <tr><td>
  536. <blockquote>
  537. <p>Ant's distribution contains file names that are longer
  538. than 100 characters, which is not supported by the standard
  539. tar file format. Several different implementations of tar use
  540. different and incompatible ways to work around this
  541. restriction.</p>
  542. <p>Ant's &lt;tar&gt; task can create tar archives that use
  543. the GNU tar extension, and this has been used when putting
  544. together the distribution. If you are using a different
  545. version of tar (for example, the one shipping with Solaris),
  546. you cannot use it to extract the archive.</p>
  547. <p>The solution is to either install GNU tar, which can be
  548. found <a href="http://www.gnu.org/software/tar/tar.html">here</a>,
  549. or use the zip archive instead (you can extract it using
  550. <code>jar xf</code>).</p>
  551. </blockquote>
  552. </td></tr>
  553. </table>
  554. </a>
  555. <a name="always-recompiles">
  556. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  557. <tr><td bgcolor="#828DA6">
  558. <font color="#ffffff" face="arial,helvetica,sanserif">
  559. <strong>
  560. Why does Ant always recompile all my Java files?
  561. </strong>
  562. </font>
  563. </td></tr>
  564. <tr><td>
  565. <blockquote>
  566. <p>In order to find out which files should be compiled, Ant
  567. compares the timestamps of the source files to those of the
  568. resulting <code>.class</code> files. Opening all source files
  569. to find out which package they belong to would be very
  570. inefficient. Instead, Ant expects you to place your
  571. source files in a directory hierarchy that mirrors your
  572. package hierarchy and to point Ant to the root of this
  573. directory tree with the <code>srcdir</code> attribute.</p>
  574. <p>Say you have <code>&lt;javac srcdir="src"
  575. destdir="dest"/&gt;</code>. If Ant finds a file
  576. <code>src/a/b/C.java</code>, it expects it to be in package
  577. <code>a.b</code> so that the resulting <code>.class</code>
  578. file is going to be <code>dest/a/b/C.class</code>.</p>
  579. <p>If your source-tree directory structure does not match your
  580. package structure, Ant's heuristic won't work, and
  581. it will recompile classes that are up-to-date. Ant is not the
  582. only tool that expects a source-tree layout like this.</p>
  583. <p>If you have Java source files that aren't declared to
  584. be part of any package, you can still use the <code>&lt;javac&gt;</code>
  585. task to compile these files correctly - just set the
  586. <code>srcdir</code> and <code>destdir</code> attributes to
  587. the actual directory the source
  588. files live in and the directory the class files should go into,
  589. respectively.</p>
  590. </blockquote>
  591. </td></tr>
  592. </table>
  593. </a>
  594. <a name="passing-cli-args">
  595. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  596. <tr><td bgcolor="#828DA6">
  597. <font color="#ffffff" face="arial,helvetica,sanserif">
  598. <strong>
  599. How do I pass parameters from the command line to my
  600. build file?
  601. </strong>
  602. </font>
  603. </td></tr>
  604. <tr><td>
  605. <blockquote>
  606. <p>Use properties. Using <code>ant
  607. -D<em>name</em>=<em>value</em></code> lets you define values for
  608. properties on the Ant command line. These properties can then be
  609. used within your build file as
  610. any normal property: <code>${<em>name</em>}</code> will put in
  611. <code><em>value</em></code>.</p>
  612. </blockquote>
  613. </td></tr>
  614. </table>
  615. </a>
  616. <a name="jikes-switches">
  617. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  618. <tr><td bgcolor="#828DA6">
  619. <font color="#ffffff" face="arial,helvetica,sanserif">
  620. <strong>
  621. How can I use Jikes-specific command-line
  622. switches?
  623. </strong>
  624. </font>
  625. </td></tr>
  626. <tr><td>
  627. <blockquote>
  628. <p>A couple of switches are supported via "magic"
  629. properties:</p>
  630. <table>
  631. <tr>
  632. <td bgcolor="#039acc" colspan="" rowspan=""
  633. valign="top" align="left">
  634. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  635. switch
  636. </font>
  637. </td>
  638. <td bgcolor="#039acc" colspan="" rowspan=""
  639. valign="top" align="left">
  640. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  641. property
  642. </font>
  643. </td>
  644. <td bgcolor="#039acc" colspan="" rowspan=""
  645. valign="top" align="left">
  646. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  647. default
  648. </font>
  649. </td>
  650. </tr>
  651. <tr>
  652. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  653. valign="top" align="left">
  654. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  655. +E
  656. </font>
  657. </td>
  658. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  659. valign="top" align="left">
  660. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  661. build.compiler.emacs
  662. </font>
  663. </td>
  664. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  665. valign="top" align="left">
  666. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  667. false == not set
  668. </font>
  669. </td>
  670. </tr>
  671. <tr>
  672. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  673. valign="top" align="left">
  674. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  675. +P
  676. </font>
  677. </td>
  678. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  679. valign="top" align="left">
  680. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  681. build.compiler.pedantic
  682. </font>
  683. </td>
  684. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  685. valign="top" align="left">
  686. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  687. false == not set
  688. </font>
  689. </td>
  690. </tr>
  691. <tr>
  692. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  693. valign="top" align="left">
  694. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  695. +F
  696. </font>
  697. </td>
  698. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  699. valign="top" align="left">
  700. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  701. build.compiler.fulldepend
  702. </font>
  703. </td>
  704. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  705. valign="top" align="left">
  706. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  707. false == not set
  708. </font>
  709. </td>
  710. </tr>
  711. <tr>
  712. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  713. valign="top" align="left">
  714. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  715. <strong>(Only for Ant &lt; 1.4; replaced by the
  716. <code><strong>nowarn</strong></code>
  717. attribute of the <code><strong>&lt;javac&gt;</strong></code>
  718. task after that.)</strong><br />-nowarn
  719. </font>
  720. </td>
  721. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  722. valign="top" align="left">
  723. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  724. build.compiler.warnings
  725. </font>
  726. </td>
  727. <td bgcolor="#a0ddf0" colspan="" rowspan=""
  728. valign="top" align="left">
  729. <font color="#000000" size="-1" face="arial,helvetica,sanserif">
  730. true == not set
  731. </font>
  732. </td>
  733. </tr>
  734. </table>
  735. </blockquote>
  736. </td></tr>
  737. </table>
  738. </a>
  739. <a name="shell-redirect-1">
  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 include a &lt; character in my command-line arguments?
  745. </strong>
  746. </font>
  747. </td></tr>
  748. <tr><td>
  749. <blockquote>
  750. <p>The short answer is "Use: <code>&amp;lt;</code>".</p>
  751. <p>The long answer is that this probably won't do what you
  752. want anyway (see <a href="#shell-redirect-2">the next
  753. section</a>).</p>
  754. </blockquote>
  755. </td></tr>
  756. </table>
  757. </a>
  758. <a name="shell-redirect-2">
  759. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  760. <tr><td bgcolor="#828DA6">
  761. <font color="#ffffff" face="arial,helvetica,sanserif">
  762. <strong>
  763. How do I redirect standard input or standard output
  764. in the <code>&lt;exec&gt;</code> task?
  765. </strong>
  766. </font>
  767. </td></tr>
  768. <tr><td>
  769. <blockquote>
  770. <p>Say you want to redirect the standard input stream of the
  771. <code>cat</code> command to read from a file, something
  772. like:</p>
  773. <div align="left">
  774. <table cellspacing="4" cellpadding="0" border="0">
  775. <tr>
  776. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  777. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  778. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  779. </tr>
  780. <tr>
  781. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  782. <td bgcolor="#ffffff"><pre>
  783. shell-prompt&gt; cat &lt; foo
  784. </pre></td>
  785. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  786. </tr>
  787. <tr>
  788. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  789. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  790. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  791. </tr>
  792. </table>
  793. </div>
  794. <p>and try to translate it into</p>
  795. <div align="left">
  796. <table cellspacing="4" cellpadding="0" border="0">
  797. <tr>
  798. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  799. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  800. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  801. </tr>
  802. <tr>
  803. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  804. <td bgcolor="#ffffff"><pre>
  805. &lt;exec executable=&quot;cat&quot;&gt;
  806. &lt;arg value=&quot;&amp;lt;&quot; /&gt;
  807. &lt;arg value=&quot;foo&quot; /&gt;
  808. &lt;/exec&gt;
  809. </pre></td>
  810. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  811. </tr>
  812. <tr>
  813. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  814. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  815. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  816. </tr>
  817. </table>
  818. </div>
  819. <p>This will not do what you expect. The input redirection is
  820. performed by your shell, not the command itself, so this
  821. should read:</p>
  822. <div align="left">
  823. <table cellspacing="4" cellpadding="0" border="0">
  824. <tr>
  825. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  826. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  827. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  828. </tr>
  829. <tr>
  830. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  831. <td bgcolor="#ffffff"><pre>
  832. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  833. &lt;arg value=&quot;-c&quot; /&gt;
  834. &lt;arg value=&quot;cat &amp;lt; foo&quot; /&gt;
  835. &lt;/exec&gt;
  836. </pre></td>
  837. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  838. </tr>
  839. <tr>
  840. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  841. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  842. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  843. </tr>
  844. </table>
  845. </div>
  846. <p>Note that you must use the <code>value</code> attribute of
  847. <code>&lt;arg&gt;</code> in the last element, in order to have
  848. the command passed as a single, quoted argument. Alternatively,
  849. you can use:</p>
  850. <div align="left">
  851. <table cellspacing="4" cellpadding="0" border="0">
  852. <tr>
  853. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  854. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  855. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  856. </tr>
  857. <tr>
  858. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  859. <td bgcolor="#ffffff"><pre>
  860. &lt;exec executable=&quot;/bin/sh&quot;&gt;
  861. &lt;arg line='-c &quot;cat &amp;lt; foo&quot;'/&gt;
  862. &lt;/exec&gt;
  863. </pre></td>
  864. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  865. </tr>
  866. <tr>
  867. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  868. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  869. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  870. </tr>
  871. </table>
  872. </div>
  873. <p>Note the double-quotes nested inside the single-quotes.</p>
  874. </blockquote>
  875. </td></tr>
  876. </table>
  877. </a>
  878. <a name="batch-shell-execute">
  879. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  880. <tr><td bgcolor="#828DA6">
  881. <font color="#ffffff" face="arial,helvetica,sanserif">
  882. <strong>
  883. How do I execute a batch file or shell script from Ant?
  884. </strong>
  885. </font>
  886. </td></tr>
  887. <tr><td>
  888. <blockquote>
  889. <p>Execute the command shell instead, then pass the batch file or
  890. shell script as a single command, using the <code>/c</code> or
  891. <code>-c</code> switch, respectively. See
  892. <a href="#shell-redirect-2">the above section</a>
  893. for example <code>&lt;exec&gt;</code> tasks
  894. executing <code>sh</code>. On Windows, use something like:</p>
  895. <div align="left">
  896. <table cellspacing="4" cellpadding="0" border="0">
  897. <tr>
  898. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  899. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  900. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  901. </tr>
  902. <tr>
  903. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  904. <td bgcolor="#ffffff"><pre>
  905. &lt;exec dir=&quot;.&quot; executable=&quot;cmd.exe&quot; os=&quot;Windows NT&quot;&gt;
  906. &lt;arg line=&quot;/c test.bat&quot;/&gt;
  907. &lt;/exec&gt;
  908. </pre></td>
  909. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  910. </tr>
  911. <tr>
  912. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  913. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  914. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  915. </tr>
  916. </table>
  917. </div>
  918. </blockquote>
  919. </td></tr>
  920. </table>
  921. </a>
  922. <a name="defaultexcludes">
  923. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  924. <tr><td bgcolor="#828DA6">
  925. <font color="#ffffff" face="arial,helvetica,sanserif">
  926. <strong>
  927. I've used a <code>&lt;delete&gt;</code> task to delete
  928. unwanted
  929. SourceSafe control files (CVS files, editor backup files, etc.), but
  930. it doesn't seem to work; the files never get deleted. What's
  931. wrong?
  932. </strong>
  933. </font>
  934. </td></tr>
  935. <tr><td>
  936. <blockquote>
  937. <p>This is probably happening because, by default, Ant excludes
  938. SourceSafe control files (<code>vssver.scc</code>) and certain other
  939. files from FileSets.</p>
  940. <p>Here's what you probably did:</p>
  941. <div align="left">
  942. <table cellspacing="4" cellpadding="0" border="0">
  943. <tr>
  944. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  945. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  946. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  947. </tr>
  948. <tr>
  949. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  950. <td bgcolor="#ffffff"><pre>
  951. &lt;delete&gt;
  952. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
  953. &lt;/delete&gt;
  954. </pre></td>
  955. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  956. </tr>
  957. <tr>
  958. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  959. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  960. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  961. </tr>
  962. </table>
  963. </div>
  964. <p>You need to switch off the default exclusions,
  965. and it will work:</p>
  966. <div align="left">
  967. <table cellspacing="4" cellpadding="0" border="0">
  968. <tr>
  969. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  970. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  971. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  972. </tr>
  973. <tr>
  974. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  975. <td bgcolor="#ffffff"><pre>
  976. &lt;delete&gt;
  977. &lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
  978. defaultexcludes=&quot;no&quot;/&gt;
  979. &lt;/delete&gt;
  980. </pre></td>
  981. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  982. </tr>
  983. <tr>
  984. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  985. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  986. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  987. </tr>
  988. </table>
  989. </div>
  990. <p>For a complete listing of the patterns that are excluded
  991. by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
  992. manual</a>.</p>
  993. </blockquote>
  994. </td></tr>
  995. </table>
  996. </a>
  997. <a name="multi-conditions">
  998. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  999. <tr><td bgcolor="#828DA6">
  1000. <font color="#ffffff" face="arial,helvetica,sanserif">
  1001. <strong>
  1002. I want to execute a particular target only if
  1003. multiple conditions are true.
  1004. </strong>
  1005. </font>
  1006. </td></tr>
  1007. <tr><td>
  1008. <blockquote>
  1009. <p>There are actually several answers to this question.</p>
  1010. <p>If you have only one set and one unset property to test,
  1011. you can specify both an <code>if</code> and an <code>unless</code>
  1012. attribute for the target, and they will act as if they
  1013. are "anded" together.</p>
  1014. <p>If you are using a version of Ant 1.3 or earlier, the
  1015. way to work with all other cases is to chain targets together
  1016. to determine the specific state you want to test for.</p>
  1017. <p>To see how this works, assume you have three properties:
  1018. <code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
  1019. You want to test that <code>prop1</code> and <code>prop2</code>
  1020. are set, and that <code>prop3</code> is not. If the condition
  1021. holds true you want to echo "yes".</p>
  1022. <p>Here is the implementation in Ant 1.3 and earlier:</p>
  1023. <div align="left">
  1024. <table cellspacing="4" cellpadding="0" border="0">
  1025. <tr>
  1026. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1027. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1028. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1029. </tr>
  1030. <tr>
  1031. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1032. <td bgcolor="#ffffff"><pre>
  1033. &lt;target name=&quot;cond&quot; depends=&quot;cond-if&quot;/&gt;
  1034. &lt;target name=&quot;cond-if&quot; if=&quot;prop1&quot;&gt;
  1035. &lt;antcall target=&quot;cond-if-2&quot;/&gt;
  1036. &lt;/target&gt;
  1037. &lt;target name=&quot;cond-if-2&quot; if=&quot;prop2&quot;&gt;
  1038. &lt;antcall target=&quot;cond-if-3&quot;/&gt;
  1039. &lt;/target&gt;
  1040. &lt;target name=&quot;cond-if-3&quot; unless=&quot;prop3&quot;&gt;
  1041. &lt;echo message=&quot;yes&quot;/&gt;
  1042. &lt;/target&gt;
  1043. </pre></td>
  1044. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1045. </tr>
  1046. <tr>
  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. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1049. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1050. </tr>
  1051. </table>
  1052. </div>
  1053. <p>Note: <code>&lt;antcall&gt;</code> tasks do <em>not</em> pass
  1054. property changes back up to the environment they were called
  1055. from, so you would'nt be able to, for example, set a
  1056. <code>result</code> property in the <code>cond-if-3</code> target,
  1057. then do
  1058. <code>&lt;echo message="result is ${result}"/&gt;</code>
  1059. in the <code>cond</code> target.</p>
  1060. <p>Starting with Ant 1.4, you can use the
  1061. <code>&lt;condition&gt;</code> task.</p>
  1062. <div align="left">
  1063. <table cellspacing="4" cellpadding="0" border="0">
  1064. <tr>
  1065. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1066. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1067. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1068. </tr>
  1069. <tr>
  1070. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1071. <td bgcolor="#ffffff"><pre>
  1072. &lt;target name=&quot;cond&quot; depends=&quot;cond-if,cond-else&quot;/&gt;
  1073. &lt;target name=&quot;check-cond&quot;&gt;
  1074. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1075. &lt;and&gt;
  1076. &lt;not&gt;
  1077. &lt;equals arg1=&quot;${prop1}&quot; arg2=&quot;$${prop1}&quot; /&gt;
  1078. &lt;/not&gt;
  1079. &lt;not&gt;
  1080. &lt;equals arg1=&quot;${prop2}&quot; arg2=&quot;$${prop2}&quot; /&gt;
  1081. &lt;/not&gt;
  1082. &lt;equals arg1=&quot;${prop3}&quot; arg2=&quot;$${prop3}&quot; /&gt;
  1083. &lt;/and&gt;
  1084. &lt;/condition&gt;
  1085. &lt;/target&gt;
  1086. &lt;target name=&quot;cond-if&quot; depends=&quot;check-cond&quot; if=&quot;cond-is-true&quot;&gt;
  1087. &lt;echo message=&quot;yes&quot;/&gt;
  1088. &lt;/target&gt;
  1089. &lt;target name=&quot;cond-else&quot; depends=&quot;check-cond&quot; unless=&quot;cond-is-true&quot;&gt;
  1090. &lt;echo message=&quot;no&quot;/&gt;
  1091. &lt;/target&gt;
  1092. </pre></td>
  1093. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1094. </tr>
  1095. <tr>
  1096. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1097. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1098. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1099. </tr>
  1100. </table>
  1101. </div>
  1102. <p>This version takes advantage of two things:</p>
  1103. <ul>
  1104. <li>If a property <code>a</code> has not been set,
  1105. <code>${a}</code> will evaluate to <code>${a}</code>.</li>
  1106. <li>To get a literal <code>$</code> in Ant, you have to
  1107. escape it with another <code>$</code> - this will also break
  1108. the special treatment of the <code>${</code> sequence.</li>
  1109. </ul>
  1110. <p>Because testing for a literal <code>${property}</code> string
  1111. isn't all that readable or easy to understand,
  1112. post-1.4.1 Ant introduces the <code>&lt;isset&gt;</code> element
  1113. to the <code>&lt;condition&gt;</code> task.</p>
  1114. <p>Here is the previous example done using
  1115. <code>&lt;isset&gt;</code>:</p>
  1116. <div align="left">
  1117. <table cellspacing="4" cellpadding="0" border="0">
  1118. <tr>
  1119. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1120. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1121. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1122. </tr>
  1123. <tr>
  1124. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1125. <td bgcolor="#ffffff"><pre>
  1126. &lt;target name=&quot;check-cond&quot;&gt;
  1127. &lt;condition property=&quot;cond-is-true&quot;&gt;
  1128. &lt;and&gt;
  1129. &lt;isset property=&quot;prop1&quot;/&gt;
  1130. &lt;isset property=&quot;prop2&quot;/&gt;
  1131. &lt;not&gt;
  1132. &lt;isset property=&quot;prop3&quot;/&gt;
  1133. &lt;/not&gt;
  1134. &lt;/and&gt;
  1135. &lt;/condition&gt;
  1136. &lt;/target&gt;
  1137. </pre></td>
  1138. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1139. </tr>
  1140. <tr>
  1141. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1142. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1143. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1144. </tr>
  1145. </table>
  1146. </div>
  1147. <p>The last option is to use a scripting language to set the
  1148. properties. This can be particularly handy when you need much
  1149. finer control than the simple conditions shown here but, of
  1150. course, comes with the overhead of adding JAR files to support
  1151. the language, to say nothing of the added maintenance in requiring
  1152. two languages to implement a single system. See the
  1153. <a href="manual/OptionalTasks/script.html">
  1154. <code>&lt;script&gt;</code> task documentation</a> for more
  1155. details.</p>
  1156. </blockquote>
  1157. </td></tr>
  1158. </table>
  1159. </a>
  1160. <a name="stop-dependency">
  1161. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1162. <tr><td bgcolor="#828DA6">
  1163. <font color="#ffffff" face="arial,helvetica,sanserif">
  1164. <strong>
  1165. I have a target I want to skip if a property is set,
  1166. so I have <code>unless="property"</code> as an attribute
  1167. of the target, but all the targets this target
  1168. depends on are still executed. Why?
  1169. </strong>
  1170. </font>
  1171. </td></tr>
  1172. <tr><td>
  1173. <blockquote>
  1174. <p>The list of dependencies is generated by Ant before any of the
  1175. targets are run. This allows dependent targets, such as an
  1176. <code>init</code> target, to set properties that can control the
  1177. execution of the targets higher in the dependency graph. This
  1178. is a good thing.</p>
  1179. <p>However, when your dependencies break down the
  1180. higher-level task
  1181. into several smaller steps, this behaviour becomes
  1182. counter-intuitive. There are a couple of solutions available:
  1183. </p>
  1184. <ol>
  1185. <li>Put the same condition on each of the dependent targets.</li>
  1186. <li>Execute the steps using <code>&lt;antcall&gt;</code>,
  1187. instead of specifying them inside the <code>depends</code>
  1188. attribute.</li>
  1189. </ol>
  1190. </blockquote>
  1191. </td></tr>
  1192. </table>
  1193. </a>
  1194. <a name="include-order">
  1195. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1196. <tr><td bgcolor="#828DA6">
  1197. <font color="#ffffff" face="arial,helvetica,sanserif">
  1198. <strong>
  1199. In my <code>&lt;fileset&gt;</code>, I've put in an
  1200. <code>&lt;exclude&gt;</code> of all files followed by an
  1201. <code>&lt;include&gt;</code> of just the files I want, but it
  1202. isn't giving me any files at all. What's wrong?
  1203. </strong>
  1204. </font>
  1205. </td></tr>
  1206. <tr><td>
  1207. <blockquote>
  1208. <p>The order of the <code>&lt;include&gt;</code> and
  1209. <code>&lt;exclude&gt;</code> tags within a <code>&lt;fileset&gt;</code>
  1210. is ignored when the FileSet is created. Instead, all of the
  1211. <code>&lt;include&gt;</code> elements are processed together,
  1212. followed by all of the <code>&lt;exclude&gt;</code>
  1213. elements. This means that the <code>&lt;exclude&gt;</code>
  1214. elements only apply to the file list produced by the
  1215. <code>&lt;include&gt;</code> elements.</p>
  1216. <p>To get the files you want, focus on just the
  1217. <code>&lt;include&gt;</code> patterns that would be necessary
  1218. to get them. If you find you need to trim the list that the
  1219. <code>&lt;include&gt;</code> elements
  1220. produce, then use <code>&lt;exclude&gt;</code> elements.</p>
  1221. </blockquote>
  1222. </td></tr>
  1223. </table>
  1224. </a>
  1225. <a name="integration">
  1226. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1227. <tr><td bgcolor="#828DA6">
  1228. <font color="#ffffff" face="arial,helvetica,sanserif">
  1229. <strong>
  1230. Is Ant supported by my IDE/Editor?
  1231. </strong>
  1232. </font>
  1233. </td></tr>
  1234. <tr><td>
  1235. <blockquote>
  1236. <p>See the <a href="external.html#IDE and Editor Integration">section
  1237. on IDE integration</a> on our External Tools and Tasks page.</p>
  1238. </blockquote>
  1239. </td></tr>
  1240. </table>
  1241. </a>
  1242. <a name="emacs-mode">
  1243. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1244. <tr><td bgcolor="#828DA6">
  1245. <font color="#ffffff" face="arial,helvetica,sanserif">
  1246. <strong>
  1247. Why doesn't (X)Emacs/vi/MacOS X's project builder
  1248. correctly parse the error messages generated by Ant?
  1249. </strong>
  1250. </font>
  1251. </td></tr>
  1252. <tr><td>
  1253. <blockquote>
  1254. <p>Ant adds a "banner" with the name of the current
  1255. task in front of all logging messages - and there are no built-in
  1256. regular expressions in your editor that would account for
  1257. this.</p>
  1258. <p>You can disable this banner by invoking Ant with the
  1259. <code>-emacs</code> switch. Alternatively, you can add the
  1260. following snippet to your <code>.emacs</code> to make Emacs
  1261. understand Ant's output.</p>
  1262. <div align="left">
  1263. <table cellspacing="4" cellpadding="0" border="0">
  1264. <tr>
  1265. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1266. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1267. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1268. </tr>
  1269. <tr>
  1270. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1271. <td bgcolor="#ffffff"><pre>
  1272. (require 'compile)
  1273. (setq compilation-error-regexp-alist
  1274. (append (list
  1275. ;; works for jikes
  1276. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:&quot; 1 2 3)
  1277. ;; works for javac
  1278. '(&quot;^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):&quot; 1 2))
  1279. compilation-error-regexp-alist))
  1280. </pre></td>
  1281. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1282. </tr>
  1283. <tr>
  1284. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1285. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1286. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1287. </tr>
  1288. </table>
  1289. </div>
  1290. <p>Yet another alternative that preserves most of Ant's
  1291. formatting is to pipe Ant's output through the following Perl
  1292. script by Dirk-Willem van Gulik:</p>
  1293. <div align="left">
  1294. <table cellspacing="4" cellpadding="0" border="0">
  1295. <tr>
  1296. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1297. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1298. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1299. </tr>
  1300. <tr>
  1301. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1302. <td bgcolor="#ffffff"><pre>
  1303. #!/usr/bin/perl
  1304. #
  1305. # May 2001 dirkx@apache.org - remove any
  1306. # [foo] lines from the output; keeping
  1307. # spacing more or less there.
  1308. #
  1309. $|=1;
  1310. while(&lt;STDIN&gt;) {
  1311. if (s/^(\s+)\[(\w+)\]//) {
  1312. if ($2 ne $last) {
  1313. print &quot;$1\[$2\]&quot;;
  1314. $s = ' ' x length($2);
  1315. } else {
  1316. print &quot;$1 $s &quot;;
  1317. };
  1318. $last = $2;
  1319. };
  1320. print;
  1321. };
  1322. </pre></td>
  1323. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1324. </tr>
  1325. <tr>
  1326. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1327. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1328. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1329. </tr>
  1330. </table>
  1331. </div>
  1332. </blockquote>
  1333. </td></tr>
  1334. </table>
  1335. </a>
  1336. <a name="dtd">
  1337. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1338. <tr><td bgcolor="#828DA6">
  1339. <font color="#ffffff" face="arial,helvetica,sanserif">
  1340. <strong>
  1341. Is there a DTD that I can use to validate my build
  1342. files?
  1343. </strong>
  1344. </font>
  1345. </td></tr>
  1346. <tr><td>
  1347. <blockquote>
  1348. <p>An incomplete DTD can be created by the
  1349. <code>&lt;antstructure&gt;</code> task - but this one
  1350. has a few problems:</p>
  1351. <ul>
  1352. <li>It doesn't know about required attributes. Only
  1353. manual tweaking of this file can help here.</li>
  1354. <li>It is not complete - if you add new tasks via
  1355. <code>&lt;taskdef&gt;</code> it won't know about it. See
  1356. <a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
  1357. page</a> by Michel Casabianca for a solution to this
  1358. problem. Note that the DTD you can download at this page
  1359. is based on Ant 0.3.1.</li>
  1360. <li>It may even be an invalid DTD. As Ant allows tasks
  1361. writers to define arbitrary elements, name collisions will
  1362. happen quite frequently - if your version of Ant contains
  1363. the optional <code>&lt;test&gt;</code> and
  1364. <code>&lt;junit&gt;</code> tasks, there are two XML
  1365. elements named <code>test</code> (the task and the nested child
  1366. element of <code>&lt;junit&gt;</code>) with different attribute
  1367. lists. This problem cannot be solved; DTDs don't give a
  1368. syntax rich enough to support this.</li>
  1369. </ul>
  1370. </blockquote>
  1371. </td></tr>
  1372. </table>
  1373. </a>
  1374. <a name="xml-entity-include">
  1375. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1376. <tr><td bgcolor="#828DA6">
  1377. <font color="#ffffff" face="arial,helvetica,sanserif">
  1378. <strong>
  1379. How do I include an XML snippet in my build file?
  1380. </strong>
  1381. </font>
  1382. </td></tr>
  1383. <tr><td>
  1384. <blockquote>
  1385. <p>You can use XML's way of including external files and let
  1386. the parser do the job for Ant:</p>
  1387. <div align="left">
  1388. <table cellspacing="4" cellpadding="0" border="0">
  1389. <tr>
  1390. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1391. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1392. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1393. </tr>
  1394. <tr>
  1395. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1396. <td bgcolor="#ffffff"><pre>
  1397. &lt;?xml version=&quot;1.0&quot;?&gt;
  1398. &lt;!DOCTYPE project [
  1399. &lt;!ENTITY common SYSTEM &quot;file:./common.xml&quot;&gt;
  1400. ]&gt;
  1401. &lt;project name=&quot;test&quot; default=&quot;test&quot; basedir=&quot;.&quot;&gt;
  1402. &lt;target name=&quot;setup&quot;&gt;
  1403. ...
  1404. &lt;/target&gt;
  1405. &amp;common;
  1406. ...
  1407. &lt;/project&gt;
  1408. </pre></td>
  1409. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1410. </tr>
  1411. <tr>
  1412. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1413. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1414. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1415. </tr>
  1416. </table>
  1417. </div>
  1418. <p>will literally include the contents of <code>common.xml</code> where
  1419. you've placed the <code>&amp;common;</code> entity.</p>
  1420. <p>In combination with a DTD, this would look like this:</p>
  1421. <div align="left">
  1422. <table cellspacing="4" cellpadding="0" border="0">
  1423. <tr>
  1424. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1425. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1426. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1427. </tr>
  1428. <tr>
  1429. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1430. <td bgcolor="#ffffff"><pre>
  1431. &lt;!DOCTYPE project PUBLIC &quot;-//ANT//DTD project//EN&quot; &quot;file:./ant.dtd&quot; [
  1432. &lt;!ENTITY include SYSTEM &quot;file:./header.xml&quot;&gt;
  1433. ]&gt;
  1434. </pre></td>
  1435. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1436. </tr>
  1437. <tr>
  1438. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1439. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1440. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1441. </tr>
  1442. </table>
  1443. </div>
  1444. </blockquote>
  1445. </td></tr>
  1446. </table>
  1447. </a>
  1448. <a name="mail-logger">
  1449. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1450. <tr><td bgcolor="#828DA6">
  1451. <font color="#ffffff" face="arial,helvetica,sanserif">
  1452. <strong>
  1453. How do I send an email with the result of my build
  1454. process?
  1455. </strong>
  1456. </font>
  1457. </td></tr>
  1458. <tr><td>
  1459. <blockquote>
  1460. <p>If you are using a nightly build of Ant 1.5 after
  1461. 2001-12-14, you can use the built-in MailLogger:</p>
  1462. <div align="left">
  1463. <table cellspacing="4" cellpadding="0" border="0">
  1464. <tr>
  1465. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1466. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1467. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1468. </tr>
  1469. <tr>
  1470. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1471. <td bgcolor="#ffffff"><pre>
  1472. ant -logger org.apache.tools.ant.listener.MailLogger
  1473. </pre></td>
  1474. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1475. </tr>
  1476. <tr>
  1477. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1478. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1479. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1480. </tr>
  1481. </table>
  1482. </div>
  1483. <p>See the <a href="http://cvs.apache.org/viewcvs/~checkout~/jakarta-ant/docs/manual/listeners.html?content-type=text/html">Listeners
  1484. &amp; Loggers</a> documentation for details on the properties
  1485. required.</p>
  1486. <p>For older versions of Ant, you can use a custom
  1487. BuildListener that sends out an email
  1488. in the buildFinished() method. Will Glozer
  1489. &lt;will.glozer@jda.com&gt; has written such a listener based
  1490. on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
  1491. The source is:</p>
  1492. <div align="left">
  1493. <table cellspacing="4" cellpadding="0" border="0">
  1494. <tr>
  1495. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1496. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1497. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1498. </tr>
  1499. <tr>
  1500. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1501. <td bgcolor="#ffffff"><pre>
  1502. import java.io.*;
  1503. import java.util.*;
  1504. import javax.mail.*;
  1505. import javax.mail.internet.*;
  1506. import org.apache.tools.ant.*;
  1507. /**
  1508. * A simple listener that waits for a build to finish and sends an email
  1509. * of the results. The settings are stored in &quot;monitor.properties&quot; and
  1510. * are fairly self explanatory.
  1511. *
  1512. * @author Will Glozer
  1513. * @version 1.05a 09/06/2000
  1514. */
  1515. public class BuildMonitor implements BuildListener {
  1516. protected Properties props;
  1517. /**
  1518. * Create a new BuildMonitor.
  1519. */
  1520. public BuildMonitor() throws Exception {
  1521. props = new Properties();
  1522. InputStream is = getClass().getResourceAsStream(&quot;monitor.properties&quot;);
  1523. props.load(is);
  1524. is.close();
  1525. }
  1526. public void buildStarted(BuildEvent e) {
  1527. }
  1528. /**
  1529. * Determine the status of the build and the actions to follow, now that
  1530. * the build has completed.
  1531. *
  1532. * @param e Event describing the build tatus.
  1533. */
  1534. public void buildFinished(BuildEvent e) {
  1535. Throwable th = e.getException();
  1536. String status = (th != null) ? &quot;failed&quot; : &quot;succeeded&quot;;
  1537. try {
  1538. String key = &quot;build.&quot; + status;
  1539. if (props.getProperty(key + &quot;.notify&quot;).equalsIgnoreCase(&quot;false&quot;)) {
  1540. return;
  1541. }
  1542. Session session = Session.getDefaultInstance(props, null);
  1543. MimeMessage message = new MimeMessage(session);
  1544. message.addRecipients(Message.RecipientType.TO, parseAddresses(
  1545. props.getProperty(key + &quot;.email.to&quot;)));
  1546. message.setSubject(props.getProperty(key + &quot;.email.subject&quot;));
  1547. BufferedReader br = new BufferedReader(new FileReader(
  1548. props.getProperty(&quot;build.log&quot;)));
  1549. StringWriter sw = new StringWriter();
  1550. String line = br.readLine();
  1551. while (line != null) {
  1552. sw.write(line);
  1553. sw.write(&quot;\n&quot;);
  1554. line = br.readLine();
  1555. }
  1556. br.close();
  1557. message.setText(sw.toString(), &quot;UTF-8&quot;);
  1558. sw.close();
  1559. Transport transport = session.getTransport();
  1560. transport.connect();
  1561. transport.send(message);
  1562. transport.close();
  1563. } catch (Exception ex) {
  1564. System.out.println(&quot;BuildMonitor failed to send email!&quot;);
  1565. ex.printStackTrace();
  1566. }
  1567. }
  1568. /**
  1569. * Parse a comma separated list of internet email addresses.
  1570. *
  1571. * @param s The list of addresses.
  1572. * @return Array of Addresses.
  1573. */
  1574. protected Address[] parseAddresses(String s) throws Exception {
  1575. StringTokenizer st = new StringTokenizer(s, &quot;,&quot;);
  1576. Address[] addrs = new Address[st.countTokens()];
  1577. for (int i = 0; i &lt; addrs.length; i++) {
  1578. addrs[i] = new InternetAddress(st.nextToken());
  1579. }
  1580. return addrs;
  1581. }
  1582. public void messageLogged(BuildEvent e) {
  1583. }
  1584. public void targetStarted(BuildEvent e) {
  1585. }
  1586. public void targetFinished(BuildEvent e) {
  1587. }
  1588. public void taskStarted(BuildEvent e) {
  1589. }
  1590. public void taskFinished(BuildEvent e) {
  1591. }
  1592. }
  1593. </pre></td>
  1594. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1595. </tr>
  1596. <tr>
  1597. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1598. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1599. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1600. </tr>
  1601. </table>
  1602. </div>
  1603. <p>With a <code>monitor.properties</code> like this:</p>
  1604. <div align="left">
  1605. <table cellspacing="4" cellpadding="0" border="0">
  1606. <tr>
  1607. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1608. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1609. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1610. </tr>
  1611. <tr>
  1612. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1613. <td bgcolor="#ffffff"><pre>
  1614. # configuration for build monitor
  1615. mail.transport.protocol=smtp
  1616. mail.smtp.host=&lt;host&gt;
  1617. mail.from=Will Glozer &lt;will.glozer@jda.com&gt;
  1618. build.log=build.log
  1619. build.failed.notify=true
  1620. build.failed.email.to=will.glozer@jda.com
  1621. build.failed.email.subject=Nightly build failed!
  1622. build.succeeded.notify=true
  1623. build.succeeded.email.to=will.glozer@jda.com
  1624. build.succeeded.email.subject=Nightly build succeeded!
  1625. </pre></td>
  1626. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1627. </tr>
  1628. <tr>
  1629. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1630. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1631. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1632. </tr>
  1633. </table>
  1634. </div>
  1635. <p><code>monitor.properties</code> should be placed right next
  1636. to your compiled <code>BuildMonitor.class</code>. To use it,
  1637. invoke Ant like:</p>
  1638. <div align="left">
  1639. <table cellspacing="4" cellpadding="0" border="0">
  1640. <tr>
  1641. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1642. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1643. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1644. </tr>
  1645. <tr>
  1646. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1647. <td bgcolor="#ffffff"><pre>
  1648. ant -listener BuildMonitor -logfile build.log
  1649. </pre></td>
  1650. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1651. </tr>
  1652. <tr>
  1653. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1654. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1655. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1656. </tr>
  1657. </table>
  1658. </div>
  1659. <p>Make sure that <code>mail.jar</code> from JavaMail and
  1660. <code>activation.jar</code> from the
  1661. <a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
  1662. Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
  1663. </blockquote>
  1664. </td></tr>
  1665. </table>
  1666. </a>
  1667. <a name="listener-properties">
  1668. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1669. <tr><td bgcolor="#828DA6">
  1670. <font color="#ffffff" face="arial,helvetica,sanserif">
  1671. <strong>
  1672. How do I get at the properties that Ant was running
  1673. with from inside BuildListener?
  1674. </strong>
  1675. </font>
  1676. </td></tr>
  1677. <tr><td>
  1678. <blockquote>
  1679. <p>You can get at a hashtable with all the properties that Ant
  1680. has been using through the BuildEvent parameter. For
  1681. example:</p>
  1682. <div align="left">
  1683. <table cellspacing="4" cellpadding="0" border="0">
  1684. <tr>
  1685. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1686. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1687. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1688. </tr>
  1689. <tr>
  1690. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1691. <td bgcolor="#ffffff"><pre>
  1692. public void buildFinished(BuildEvent e) {
  1693. Hashtable table = e.getProject().getProperties();
  1694. String buildpath = (String)table.get(&quot;build.path&quot;);
  1695. ...
  1696. }
  1697. </pre></td>
  1698. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1699. </tr>
  1700. <tr>
  1701. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1702. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1703. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1704. </tr>
  1705. </table>
  1706. </div>
  1707. <p>This is more accurate than just reading the same property
  1708. files that your project does, since it will give the correct
  1709. results for properties that were specified on the Ant command line.</p>
  1710. </blockquote>
  1711. </td></tr>
  1712. </table>
  1713. </a>
  1714. <a name="remove-cr">
  1715. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1716. <tr><td bgcolor="#828DA6">
  1717. <font color="#ffffff" face="arial,helvetica,sanserif">
  1718. <strong>
  1719. &lt;chmod&gt; or &lt;exec&gt; doesn't work in Ant
  1720. 1.3 on Unix
  1721. </strong>
  1722. </font>
  1723. </td></tr>
  1724. <tr><td>
  1725. <blockquote>
  1726. <p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
  1727. has DOS instead of Unix line endings; you must remove the
  1728. carriage-return characters from this file. This can be done by
  1729. using Ant's <code>&lt;fixcrlf&gt;</code> task
  1730. or something like:</p>
  1731. <div align="left">
  1732. <table cellspacing="4" cellpadding="0" border="0">
  1733. <tr>
  1734. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1735. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1736. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1737. </tr>
  1738. <tr>
  1739. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1740. <td bgcolor="#ffffff"><pre>
  1741. tr -d '\r' &lt; $ANT_HOME/bin/antRun &gt; /tmp/foo
  1742. mv /tmp/foo $ANT_HOME/bin/antRun
  1743. </pre></td>
  1744. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1745. </tr>
  1746. <tr>
  1747. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1748. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1749. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  1750. </tr>
  1751. </table>
  1752. </div>
  1753. </blockquote>
  1754. </td></tr>
  1755. </table>
  1756. </a>
  1757. <a name="javadoc-cannot-execute">
  1758. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  1759. <tr><td bgcolor="#828DA6">
  1760. <font color="#ffffff" face="arial,helvetica,sanserif">
  1761. <strong>
  1762. JavaDoc failed: java.io.IOException: javadoc: cannot execute
  1763. </strong>
  1764. </font>
  1765. </td></tr>
  1766. <tr><td>
  1767. <blockquote>
  1768. <p>There is a bug in the Solaris reference implementation of
  1769. 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>).
  1770. This also appears to be true under Linux. Moving the JDK to
  1771. the front of the PATH fixes the problem.</p>
  1772. </blockquote>
  1773. </td></tr>
  1774. </table>
  1775. </a>
  1776. </blockquote>
  1777. </td></tr>
  1778. </table>
  1779. </td>
  1780. </tr>
  1781. <!-- FOOTER -->
  1782. <tr><td colspan="2">
  1783. <hr noshade="" size="1"/>
  1784. </td></tr>
  1785. <tr><td colspan="2">
  1786. <div align="center"><font color="#525D76" size="-1"><em>
  1787. Copyright &#169; 2000-2002, Apache Software Foundation
  1788. </em></font></div>
  1789. </td></tr>
  1790. </table>
  1791. </body>
  1792. </html>
  1793. <!-- end the processing -->