You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

faq.html 99 kB

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