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

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