An Informal Contract for a Custom Task

One very useful design feature found in Ant is the decoupling that exists between Ant and its tasks. The code makes direct references only to the abstract class org.apache.tools.ant.Task. In doing so, Ant provides us with a plug point that we can use to add in our custom task. If we extend org.apache.tools.ant.Task, we’ll have created our first custom task. Now, to get it to do something, we must provide an implementation for the method public void execute() throws BuildException. As previously mentioned, for Ant to be able to see the new class, a mapping between the class and the task’s name (as it appears in the build script) must be provided.

If it’s decided that the mapping will be specified in the ...

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.