O'Reilly logo

Ant: The Definitive Guide by Jesse Tilly, Eric M. Burke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The BuildListener Interface

Ant, via its event framework, tracks a variety of build-processing events using listener classes implementing the BuildListener interface. The design of the BuildListener interface and its implementation follows a pattern similar to the AWT[41] concept of listeners. In both models, an engine propagates events, whether the events are system or user-driven. Classes that wish to receive these events register themselves as listeners (in this case to the Ant engine), usually making restrictions through interface types on the kinds of events they wish to receive. When an event occurs, the engine tells all of the listeners that have registered for the event type in question. Using BuildEvent objects, the Ant engine passes detailed information to the listeners. This communication model makes Ant the most flexible build system available, because it doesn’t force the user to rely on complicated parsing of Ant’s output.

Below are the event types and their corresponding interface methods:

buildStarted(BuildEvent event)

Ant fires the buildStarted event when it begins processing the buildfile. Listeners implementing this method can perform actions when the build starts.

buildFinished(BuildEvent event)

Ant fires the buildFinished event when it has finished processing. Nothing happens in the Ant engine after this event. Consider this the final message for any given build.

targetStarted(BuildEvent event)

Ant fires the targetStarted event just before processing a target’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required