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

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