Custom Listeners

On startup, Ant registers all listeners that were specified on the command line with the project. During the build, the listener is notified of several build events and is sent log messages. Ant build events are listed in Table 6.5. Each Ant listener implements the org.apache.tools.ant.BuildListener interface. To build our own custom listener, all we need to do is implement that interface.

Table 6.5. Ant Build Events
Event Timing
Build Started Fired at the beginning of the build
Build Finished Fired on completion of the build
Target Started Fired when a target is started
Target Finished Fired when a target is started
Task Started Fired when a task has been started
Task Finished Fired when a task completes
Log Message Fired ...

Get Ant Developer’s Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.