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

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