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

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