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

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