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

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