K.3. Ant Hooks

In order to make it possible for users to add additional steps to the build process, abuild's ant code makes extensive use of hooks.

Since hooks are called in separate projects from the main build, it is not useful to set properties from hook targets and expect them to be available to later targets not invoked directly by the hook.

We define several hooks whose names start with -pre- or -post-. These hooks are run before and after the corresponding target, and they are run even when the target itself is not being run. For example, the -post-package hook may be run even if the package target is not run. This makes it possible to implement packaging or compilation strategies, for example, that would be beyond abuild's ant code's ordinary purview. An example may be the implementation of a wrapper post-package hook that can create a wrapper around things in an item's classpath even if that item itself doesn't generate any new packages.

The following hooks are defined:

Any file that provides hooks must create an ant-hooks.xml file. For each hook that it wants to provide, it should create a target called -hook where hook is replaced by the hook name above. For example, a hook file that provides a generate hook would define a target called -generate. [67]

[67] We use target names that start with a hyphen (“-”) because ant considers these to be private targets. This prevents users from invoking them explicitly from the command line but still allows them to be invoked as dependencies of other targets.