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 ...
Get Ant: The Definitive Guide 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.