|
Myrmidon
User Guide
Extending Ant
Container Design
|
|
My First Task
|
In ant1 it was very easy to write your own task. In Ant2 we plan
to make it even easier. To write a basic task simply follow the following
formula.
-
Create a Java class that extends
org.apache.myrmidon.api.AbstractTask
-
For each attribute, write a setter method. The setter method
must be a public void method that takes a single argument. The name
of the method must begin with "set", followed by the attribute name, with
the first character of the name in uppercase, and the rest in lowercase.
The type of the attribute can be:
- String
-
Any primitive type - they are converted for you from their
String-representation in the buildfile
-
File - the string representation will be interpreted relative to
the project's basedir.
-
For each nested element create a public void method that takes a single
argument. The name of the method must begin with "add", followed by the
attribute name, with the first character of the name in uppercase, and
the rest in lowercase. The type of the parameter is an object with a
no-arguement constructor. It is configured in exactly the same was a
task is configured (via setters and adders) and then added to the task.
-
Write a public void method named "execute" with no arguments that
throws a TaskException. This is the method called to do the
actual work of the task.
|
|