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.

listeners.html 22 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
  19. <title>Listeners &amp; Loggers</title>
  20. </head>
  21. <body>
  22. <h1>Listeners &amp; Loggers</h1>
  23. <h2><a name="Overview">Overview</a></h2>
  24. <p>Apache Ant has two related features to allow the build process to be monitored:
  25. listeners and loggers.</p>
  26. <h3><a name="Listeners">Listeners</a></h3>
  27. <p>A listener is alerted of the following events:</p>
  28. <ul>
  29. <li>build started</li>
  30. <li>build finished</li>
  31. <li>target started</li>
  32. <li>target finished</li>
  33. <li>task started</li>
  34. <li>task finished</li>
  35. <li>message logged</li>
  36. </ul>
  37. <p>
  38. These are used internally for various recording and housekeeping operations,
  39. however new listeners may registered on the command line through the <code>-listener</code>
  40. argument.
  41. </p>
  42. <h3><a name="Loggers">Loggers</a></h3>
  43. <p>Loggers extend the capabilities of listeners and add the following features:</p>
  44. <ul>
  45. <li>Receives a handle to the standard output and error print streams and
  46. therefore can log information to the console or the <code>-logfile</code> specified file.</li>
  47. <li>Logging level (-quiet, -verbose, -debug) aware</li>
  48. <li>Emacs-mode aware</li>
  49. </ul>
  50. <h2><a name="builtin">Built-in Listeners/Loggers</a></h2>
  51. <table border="1" cellspacing="1" width="100%" id="AutoNumber1">
  52. <tr>
  53. <td width="33%">Classname</td>
  54. <td width="33%">Description</td>
  55. <td width="34%">Type</td>
  56. </tr>
  57. <tr>
  58. <td width="33%"><code><a href="#DefaultLogger">org.apache.tools.ant.DefaultLogger</a></code></td>
  59. <td width="33%">The logger used implicitly unless overridden with the
  60. <code>-logger</code> command-line switch.</td>
  61. <td width="34%">BuildLogger</td>
  62. </tr>
  63. <tr>
  64. <td width="33%"><code><a href="#NoBannerLogger">
  65. org.apache.tools.ant.NoBannerLogger</a></code></td>
  66. <td width="33%">This logger omits output of empty target output.</td>
  67. <td width="34%">BuildLogger</td>
  68. </tr>
  69. <tr>
  70. <td width="33%"><code><a href="#MailLogger">
  71. org.apache.tools.ant.listener.MailLogger</a></code></td>
  72. <td width="33%">Extends DefaultLogger such that output is still generated
  73. the same, and when the build is finished an e-mail can be sent.</td>
  74. <td width="34%">BuildLogger</td>
  75. </tr>
  76. <tr>
  77. <td width="33%"><code><a href="#AnsiColorLogger">
  78. org.apache.tools.ant.listener.AnsiColorLogger</a></code></td>
  79. <td width="33%">Colorifies the build output.</td>
  80. <td width="34%">BuildLogger</td>
  81. </tr>
  82. <tr>
  83. <td width="33%"><code><a href="#Log4jListener">
  84. org.apache.tools.ant.listener.Log4jListener</a></code></td>
  85. <td width="33%">Passes events to Log4j for highly customizable logging.</td>
  86. <td width="34%">BuildListener</td>
  87. </tr>
  88. <tr>
  89. <td width="33%"><code><a href="#XmlLogger">org.apache.tools.ant.XmlLogger</a></code></td>
  90. <td width="33%">Writes the build information to an XML file.</td>
  91. <td width="34%">BuildLogger</td>
  92. </tr>
  93. <tr>
  94. <td width="33%"><code><a href="#TimestampedLogger">org.apache.tools.ant.TimestampedLogger</a></code></td>
  95. <td width="33%">Prints the time that a build finished</td>
  96. <td width="34%">BuildLogger</td>
  97. </tr>
  98. <tr>
  99. <td width="33%"><code><a href="#BigProjectLogger">org.apache.tools.ant.listener.BigProjectLogger</a></code></td>
  100. <td width="33%">Prints the project name every target</td>
  101. <td width="34%">BuildLogger</td>
  102. </tr>
  103. <tr>
  104. <td width="33%"><code><a href="#SimpleBigProjectLogger">org.apache.tools.ant.listener.SimpleBigProjectLogger</a></code></td>
  105. <td width="33%">Prints the project name for subprojects only, otherwise like NoBannerLogger <em>Since Ant 1.8.1</em></td>
  106. <td width="34%">BuildLogger</td>
  107. </tr>
  108. <tr>
  109. <td width="33%"><code><a href="#ProfileLogger">org.apache.tools.ant.listener.ProfileLogger</a></code></td>
  110. <td width="33%">The default logger, with start times, end times and
  111. durations added for each task and target.</td>
  112. <td width="34%">BuildLogger</td>
  113. </tr>
  114. </table>
  115. <h3><a name="DefaultLogger">DefaultLogger</a></h3>
  116. <p>Simply run Ant normally, or:</p>
  117. <blockquote>
  118. <p><code>ant -logger org.apache.tools.ant.DefaultLogger</code></p>
  119. </blockquote>
  120. <h3><a name="NoBannerLogger">NoBannerLogger</a></h3>
  121. <p>Removes output of empty target output.</p>
  122. <blockquote>
  123. <p><code>ant -logger org.apache.tools.ant.NoBannerLogger</code></p>
  124. </blockquote>
  125. <h3><a name="MailLogger">MailLogger</a></h3>
  126. <p>The MailLogger captures all output logged through DefaultLogger (standard Ant
  127. output) and will send success and failure messages to unique e-mail lists, with
  128. control for turning off success or failure messages individually.</p>
  129. <p>Properties controlling the operation of MailLogger:</p>
  130. <table border="1" cellspacing="1" width="100%" id="AutoNumber2">
  131. <tr>
  132. <th width="337">Property</th>
  133. <th width="63%">Description</th>
  134. <th width="63%">Required</th>
  135. </tr>
  136. <tr>
  137. <td width="337">MailLogger.mailhost </td>
  138. <td width="63%">Mail server to use</td>
  139. <td width="63%">No, default &quot;localhost&quot;</td>
  140. </tr>
  141. <tr>
  142. <td width="337">MailLogger.port </td>
  143. <td width="63%">SMTP Port for the Mail server</td>
  144. <td width="63%">No, default &quot;25&quot;</td>
  145. </tr>
  146. <tr>
  147. <td width="337">MailLogger.user</td>
  148. <td width="63%">user name for SMTP auth</td>
  149. <td width="63%">Yes, if SMTP auth is required on your SMTP server<br>
  150. the email message will be then sent using Mime and requires JavaMail</td>
  151. </tr>
  152. <tr>
  153. <td width="337">MailLogger.password</td>
  154. <td width="63%">password for SMTP auth</td>
  155. <td width="63%">Yes, if SMTP auth is required on your SMTP server<br>
  156. the email message will be then sent using Mime and requires JavaMail</td>
  157. </tr>
  158. <tr>
  159. <td width="337">MailLogger.ssl</td>
  160. <td width="63%">on or true if ssl is needed<br>
  161. This feature requires JavaMail</td>
  162. <td width="63%">
  163. no</td>
  164. </tr>
  165. <tr>
  166. <td width="337">MailLogger.from</td>
  167. <td width="63%">Mail &quot;from&quot; address</td>
  168. <td width="63%">Yes, if mail needs to be sent</td>
  169. </tr>
  170. <tr>
  171. <td width="337">MailLogger.replyto</td>
  172. <td width="63%">Mail &quot;replyto&quot; address(es), comma-separated</td>
  173. <td width="63%">No</td>
  174. </tr>
  175. <tr>
  176. <td width="337">MailLogger.failure.notify </td>
  177. <td width="63%">Send build failure e-mails?</td>
  178. <td width="63%">No, default &quot;true&quot;</td>
  179. </tr>
  180. <tr>
  181. <td width="337">MailLogger.success.notify </td>
  182. <td width="63%">Send build success e-mails?</td>
  183. <td width="63%">No, default &quot;true&quot;</td>
  184. </tr>
  185. <tr>
  186. <td width="337">MailLogger.failure.to </td>
  187. <td width="63%">Address(es) to send failure messages to, comma-separated</td>
  188. <td width="63%">Yes, if failure mail is to be sent</td>
  189. </tr>
  190. <tr>
  191. <td width="337">MailLogger.success.to </td>
  192. <td width="63%">Address(es) to send success messages to, comma-separated</td>
  193. <td width="63%">Yes, if success mail is to be sent</td>
  194. </tr>
  195. <tr>
  196. <td width="337">MailLogger.failure.subject </td>
  197. <td width="63%">Subject of failed build</td>
  198. <td width="63%">No, default &quot;Build Failure&quot;</td>
  199. </tr>
  200. <tr>
  201. <td width="337">MailLogger.success.subject </td>
  202. <td width="63%">Subject of successful build</td>
  203. <td width="63%">No, default &quot;Build Success&quot;</td>
  204. </tr>
  205. <tr>
  206. <td width="337">MailLogger.failure.body</td>
  207. <td width="63%">Fixed body of the email for a failed
  208. build. <em>Since Ant 1.8.0</em></td>
  209. <td width="63%">No, default is to send the full log output.</td>
  210. </tr>
  211. <tr>
  212. <td width="337">MailLogger.success.body</td>
  213. <td width="63%">Fixed body of the email for a successful
  214. build. <em>Since Ant 1.8.0</em></td>
  215. <td width="63%">No, default is to send the full log output.</td>
  216. </tr>
  217. <tr>
  218. <td width="337">MailLogger.mimeType</td>
  219. <td width="63%">MIME-Type of the message. <em>Since Ant 1.8.0</em></td>
  220. <td width="63%">No, default is text/plain</td>
  221. </tr>
  222. <tr>
  223. <td width="337">MailLogger.charset</td>
  224. <td width="63%">Character set of the message. <em>Since Ant 1.8.0</em></td>
  225. <td width="63%">No</td>
  226. </tr>
  227. <tr>
  228. <td width="337">MailLogger.starttls.enable</td>
  229. <td width="63%">on or true if STARTTLS should be supported
  230. (requires JavaMail). <em>Since Ant 1.8.0</em></td>
  231. <td width="63%">No, default is false</td>
  232. </tr>
  233. <tr>
  234. <td width="337">MailLogger.properties.file </td>
  235. <td width="63%">Filename of properties file that will override other values.</td>
  236. <td width="63%">No</td>
  237. </tr>
  238. </table>
  239. <blockquote>
  240. <p><code>ant -logger org.apache.tools.ant.listener.MailLogger</code></p>
  241. </blockquote>
  242. <h3><a name="AnsiColorLogger">AnsiColorLogger</a></h3>
  243. <p>The AnsiColorLogger adds color to the standard Ant output
  244. by prefixing and suffixing ANSI color code escape sequences to
  245. it. It is just an extension of <a href="#DefaultLogger">DefaultLogger</a>
  246. and hence provides all features that DefaultLogger does.</p>
  247. <p>AnsiColorLogger differentiates the output by assigning
  248. different colors depending upon the type of the message.</p>
  249. <p>If used with the -logfile option, the output file
  250. will contain all the necessary escape codes to
  251. display the text in colorized mode when displayed
  252. in the console using applications like cat, more, etc.</p>
  253. <p>This is designed to work on terminals that support ANSI
  254. color codes. It works on XTerm, ETerm, Win9x Console
  255. (with ANSI.SYS loaded.), etc.</p>
  256. <p><Strong>NOTE:</Strong>
  257. It doesn't work on WinNT and successors, even when a COMMAND.COM console loaded with
  258. ANSI.SYS is used.</p>
  259. <p>If the user wishes to override the default colors
  260. with custom ones, a file containing zero or more of the
  261. custom color key-value pairs must be created. The recognized keys
  262. and their default values are shown below:</p><code><pre>
  263. AnsiColorLogger.ERROR_COLOR=2;31
  264. AnsiColorLogger.WARNING_COLOR=2;35
  265. AnsiColorLogger.INFO_COLOR=2;36
  266. AnsiColorLogger.VERBOSE_COLOR=2;32
  267. AnsiColorLogger.DEBUG_COLOR=2;34</pre></code>
  268. <p>Each key takes as value a color combination defined as
  269. <b>Attribute;Foreground;Background</b>. In the above example, background
  270. value has not been used.</p>
  271. <p>This file must be specified as the value of a system variable
  272. named ant.logger.defaults and passed as an argument using the -D
  273. option to the <b>java</b> command that invokes the Ant application.
  274. An easy way to achieve this is to add -Dant.logger.defaults=
  275. <i>/path/to/your/file</i> to the ANT_OPTS environment variable.
  276. Ant's launching script recognizes this flag and will pass it to
  277. the java command appropriately.</p>
  278. <p>Format:</p><pre>
  279. AnsiColorLogger.*=Attribute;Foreground;Background
  280. Attribute is one of the following:
  281. 0 -&gt; Reset All Attributes (return to normal mode)
  282. 1 -&gt; Bright (Usually turns on BOLD)
  283. 2 -&gt; Dim
  284. 3 -&gt; Underline
  285. 5 -&gt; link
  286. 7 -&gt; Reverse
  287. 8 -&gt; Hidden
  288. Foreground is one of the following:
  289. 30 -&gt; Black
  290. 31 -&gt; Red
  291. 32 -&gt; Green
  292. 33 -&gt; Yellow
  293. 34 -&gt; Blue
  294. 35 -&gt; Magenta
  295. 36 -&gt; Cyan
  296. 37 -&gt; White
  297. Background is one of the following:
  298. 40 -&gt; Black
  299. 41 -&gt; Red
  300. 42 -&gt; Green
  301. 43 -&gt; Yellow
  302. 44 -&gt; Blue
  303. 45 -&gt; Magenta
  304. 46 -&gt; Cyan
  305. 47 -&gt; White</pre>
  306. <blockquote>
  307. <p><code>ant -logger org.apache.tools.ant.listener.AnsiColorLogger</code></p>
  308. </blockquote>
  309. <h3><a name="Log4jListener">Log4jListener</a></h3>
  310. <p>Passes build events to Log4j, using the full classname's of the generator of
  311. each build event as the category:</p>
  312. <ul>
  313. <li>build started / build finished - org.apache.tools.ant.Project</li>
  314. <li>target started / target finished - org.apache.tools.ant.Target</li>
  315. <li>task started / task finished - the fully qualified classname of the task</li>
  316. <li>message logged - the classname of one of the above, so if a task logs a
  317. message, its classname is the category used, and so on.</li>
  318. </ul>
  319. <p>All start events are logged as INFO.&nbsp; Finish events are either logged as
  320. INFO or ERROR depending on whether the build failed during that stage. Message
  321. events are logged according to their Ant logging level, mapping directly to a
  322. corresponding Log4j level.</p>
  323. <blockquote>
  324. <p><code>ant -listener org.apache.tools.ant.listener.Log4jListener</code></p>
  325. </blockquote>
  326. <p>To use Log4j you will need the Log4j JAR file and a 'log4j.properties'
  327. configuration file. Both should be placed somewhere in your Ant
  328. classpath. If the log4j.properties is in your project root folder you can
  329. add this with <i>-lib</i> option:</p>
  330. <blockquote>
  331. <pre><code>ant -listener org.apache.tools.ant.listener.Log4jListener -lib .</code></pre>
  332. </blockquote>
  333. <p>If, for example, you wanted to capture the same information output to the
  334. console by the DefaultLogger and send it to a file named 'build.log', you
  335. could use the following configuration:</p>
  336. <blockquote>
  337. <pre><code>log4j.rootLogger=ERROR, LogFile
  338. log4j.logger.org.apache.tools.ant.Project=INFO
  339. log4j.logger.org.apache.tools.ant.Target=INFO
  340. log4j.logger.org.apache.tools.ant.taskdefs=INFO
  341. log4j.logger.org.apache.tools.ant.taskdefs.Echo=WARN
  342. log4j.appender.LogFile=org.apache.log4j.FileAppender
  343. log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
  344. log4j.appender.LogFile.layout.ConversionPattern=[%6r] %8c{1} : %m%n
  345. log4j.appender.LogFile.file=build.log
  346. </code></pre>
  347. </blockquote>
  348. <p>For more information about configuring Log4J see <a href="http://logging.apache.org/log4j/docs/documentation.html">its
  349. documentation page</a>.</p>
  350. <h3><a name="XmlLogger">XmlLogger</a></h3>
  351. <p>Writes all build information out to an XML file named log.xml, or the value
  352. of the <code>XmlLogger.file</code> property if present, when used as a
  353. listener. When used as a logger, it writes all output to either the
  354. console or to the value of <code>-logfile</code>. Whether used as a listener
  355. or logger, the output is not generated until the build is complete, as it
  356. buffers the information in order to provide timing information for task,
  357. targets, and the project.</p>
  358. <p>By default the XML file creates a reference to an XSLT file "log.xsl" in the current directory;
  359. look in ANT_HOME/etc for one of these. You can set the property
  360. <code>ant.XmlLogger.stylesheet.uri</code> to provide a uri to a style sheet.
  361. this can be a relative or absolute file path, or an http URL.
  362. If you set the property to the empty string, "", no XSLT transform
  363. is declared at all.</p>
  364. <blockquote>
  365. <p><code>ant -listener org.apache.tools.ant.XmlLogger</code><br>
  366. <code>ant -logger org.apache.tools.ant.XmlLogger -verbose -logfile build_log.xml</code></p>
  367. </blockquote>
  368. <h3><a name="TimestampedLogger">TimestampedLogger</a></h3>
  369. <p>
  370. Acts like the default logger, except that the final success/failure message also includes
  371. the time that the build completed. For example:
  372. </p>
  373. <pre>
  374. BUILD SUCCESSFUL - at 16/08/05 16:24
  375. </pre>
  376. <p>To use this listener, use the command:</p>
  377. <blockquote>
  378. <code>ant -logger org.apache.tools.ant.listener.TimestampedLogger</code>
  379. </blockquote>
  380. <h3><a name="BigProjectLogger">BigProjectLogger</a></h3>
  381. <p>
  382. This logger is designed to make examining the logs of a big build easier,
  383. especially those run under continuous integration tools. It
  384. </p>
  385. <ol>
  386. <li>When entering a child project, prints its name and directory</li>
  387. <li>When exiting a child project, prints its name</li>
  388. <li>Includes the name of the project when printing a target</li>
  389. <li>Omits logging the names of all targets that have no direct task output</li>
  390. <li>Includes the build finished timestamp of the TimeStamp logger</li>
  391. </ol>
  392. <p>
  393. This is useful when using &lt;subant&gt; to build a large project
  394. from many smaller projects -the output shows which particular
  395. project is building. Here is an example in which "clean" is being called
  396. on all a number of child projects, only some of which perform work:
  397. </p>
  398. <pre>
  399. ======================================================================
  400. Entering project "xunit"
  401. In /home/ant/components/xunit
  402. ======================================================================
  403. xunit.clean:
  404. [delete] Deleting directory /home/ant/components/xunit/build
  405. [delete] Deleting directory /home/ant/components/xunit/dist
  406. ======================================================================
  407. Exiting project "xunit"
  408. ======================================================================
  409. ======================================================================
  410. Entering project "junit"
  411. In /home/ant/components/junit
  412. ======================================================================
  413. ======================================================================
  414. Exiting project "junit"
  415. ======================================================================
  416. </pre>
  417. <p>
  418. The entry and exit messages are very verbose in this example, but in
  419. a big project compiling or testing many child components, the messages
  420. are reduced to becoming clear delimiters of where different projects
  421. are in charge -or more importantly, which project is failing.
  422. </p>
  423. <p>To use this listener, use the command:</p>
  424. <blockquote>
  425. <code>ant -logger org.apache.tools.ant.listener.BigProjectLogger</code>
  426. </blockquote>
  427. <h3><a name="SimpleBigProjectLogger">SimpleBigProjectLogger</a></h3>
  428. <p>Like <code>BigProjectLogger</code>, project-qualified target names are printed,
  429. useful for big builds with subprojects.
  430. Otherwise it is as quiet as <code>NoBannerLogger</code>:</p>
  431. <pre>
  432. Buildfile: /sources/myapp/build.xml
  433. myapp-lib.compile:
  434. Created dir: /sources/myapp/lib/build/classes
  435. Compiling 1 source file to /sources/myapp/lib/build/classes
  436. myapp-lib.jar:
  437. Building jar: /sources/myapp/lib/build/lib.jar
  438. myapp.compile:
  439. Created dir: /sources/myapp/build/classes
  440. Compiling 2 source files to /sources/myapp/build/classes
  441. myapp.jar:
  442. Building jar: /sources/myapp/build/myapp.jar
  443. BUILD SUCCESSFUL
  444. Total time: 1 second
  445. </pre>
  446. <p><b>since Ant 1.8.1</b></p>
  447. <p>To use this listener, use the command:</p>
  448. <blockquote>
  449. <code>ant -logger org.apache.tools.ant.listener.SimpleBigProjectLogger</code>
  450. </blockquote>
  451. <h3><a name="ProfileLogger">ProfileLogger</a></h3>
  452. <p>This logger stores the time needed for executing a task, target and the whole build and prints
  453. these information. The output contains a timestamp when entering the build, target or task and a timestamp and the needed time when exiting.
  454. </p>
  455. <!-- This is the 'since' as described in the Loggers JavaDoc -->
  456. <p><b>since Ant 1.8.0</b></p>
  457. <h4>Example</h4>
  458. Having that buildfile
  459. <pre>
  460. &lt;project&gt;
  461. &lt;target name=&quot;aTarget&quot;&gt;
  462. &lt;echo&gt;echo-task&lt;/echo&gt;
  463. &lt;zip destfile=&quot;my.zip&quot;&gt;
  464. &lt;fileset dir=&quot;${ant.home}&quot;/&gt;
  465. &lt;/zip&gt;
  466. &lt;/target&gt;
  467. &lt;target name=&quot;anotherTarget&quot; depends=&quot;aTarget&quot;&gt;
  468. &lt;echo&gt;another-echo-task&lt;/echo&gt;
  469. &lt;/target&gt;
  470. &lt;/project&gt;
  471. </pre>
  472. and executing with <tt>ant -logger org.apache.tools.ant.listener.ProfileLogger anotherTarget</tt> gives that output (with other timestamps and duration of course ;) :
  473. <pre>
  474. Buildfile: ...\build.xml
  475. Target aTarget: started Thu Jan 22 09:01:00 CET 2009
  476. echo: started Thu Jan 22 09:01:00 CET 2009
  477. [echo] echo-task
  478. echo: finished Thu Jan 22 09:01:00 CET 2009 (250ms)
  479. zip: started Thu Jan 22 09:01:00 CET 2009
  480. [zip] Building zip: ...\my.zip
  481. zip: finished Thu Jan 22 09:01:01 CET 2009 (1313ms)
  482. Target aTarget: finished Thu Jan 22 09:01:01 CET 2009 (1719ms)
  483. Target anotherTarget: started Thu Jan 22 09:01:01 CET 2009
  484. echo: started Thu Jan 22 09:01:01 CET 2009
  485. [echo] another-echo-task
  486. echo: finished Thu Jan 22 09:01:01 CET 2009 (0ms)
  487. Target anotherTarget: finished Thu Jan 22 09:01:01 CET 2009 (0ms)
  488. BUILD SUCCESSFUL
  489. Total time: 2 seconds
  490. </pre>
  491. <h2><a name="dev">Writing your own</a></h2>
  492. <p>See the <a href="develop.html#buildevents">Build Events</a> section for
  493. developers.</p>
  494. <p>Notes:</p>
  495. <ul>
  496. <li>
  497. A listener or logger should not write to standard output or error in the <code>messageLogged() method</code>;
  498. Ant captures these internally and it will trigger an infinite loop.
  499. </li>
  500. <li>
  501. Logging is synchronous; all listeners and loggers are called one after the other, with the build blocking until
  502. the output is processed. Slow logging means a slow build.
  503. </li>
  504. <li>When a build is started, and <code>BuildListener.buildStarted(BuildEvent event)</code> is called,
  505. the project is not fully functional. The build has started, yes, and the event.getProject() method call
  506. returns the Project instance, but that project is initialized with JVM and ant properties, nor has it
  507. parsed the build file yet. You cannot call <code>Project.getProperty()</code> for property lookup, or
  508. <code>Project.getName()</code> to get the project name (it will return null).
  509. </li>
  510. <li>
  511. Classes that implement <code>org.apache.tools.ant.SubBuildListener</code> receive notifications when child projects
  512. start and stop.
  513. </li>
  514. </ul>
  515. </body>
  516. </html>