Java is not a language with training wheels. It is a language for professional programmers.

— Hebert Sheildt

Create A Custom Ant Task

Ant provides a large set of tasks that are commonly used. However there might be a time when we would need to write our own Task.

With Ant, writing custom Task is quite easy; our custom task class should extend Task (abstract) class. Write setter methods for each attribute. Override the execute method.

I will take the example used in the previous article (\ant.html) further, so you’ll come to know how exactly to use the custom Tasks.


<taskdef>     ---> Adds a task to the current project such that this new task can be used in the current project.
name             ---> The name of the task.
classname   ---> The full class name implementing the data type.

MyDateTask has to extend Task (Ant API) class, it has one field (name) which represents the attribute of the custom tag.

To execute the build file, use the following command:

© Copyright © 2013 All Rights Reserved.

Free Web Hosting