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

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