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

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