Extending the Task Class
Usually, you extend an
Ant task class like org.apache.tools.ant.Task
when you write
custom tasks. Ant comes with a selection of task classes meant to be
extended:
AbstractCvsTask
Abstract CVS task class
JDBCTask
Handles JDBC configuration needed by SQL type tasks
MatchingTask
Abstract task that should be extended by tasks required to include or exclude files based on pattern matching
Pack
Abstract base class for pack tasks
Task
Generic task and the one most commonly extended
Unpack
Abstract base class for unpacking tasks
The Task
class (i.e., org.apache.tools.ant.Task
) is used for most of
this chapter, though some samples will use MatchingTask
. The methods of the Task
class appear in Table 12-2.
Table 12-2. The Task class's methods
Method | Does this |
---|---|
| Specifies the task should execute. |
| Returns the task's description. |
| Returns the file and location at which the task is supported. |
| Returns the target that contains this task. |
| Returns the wrapper class instance the task uses for runtime configuration. |
| Returns the task name (used when when logging messages from the task). |
| Returns the type of task as a string. |
| Returns the runtime configurable structure for this
task as a |
|
Get Ant: The Definitive Guide, 2nd Edition 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.