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

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