Name
taskdef
Synopsis
Adds a task to the current project. This is used to define tasks not
already defined in the
ant.jar
’s
default.properties
file.
Attributes
-
classname
(all, String, *) The class that implements the task.
-
classpath
(all, Path, N) The classpath to use.
-
file
(1.4, File, N) The name of a properties file containing one or more task definitions. Each line is formatted like this:
taskname=full.package.name.TaskClass
-
name
(all, String, *) The name of the task.
-
resource
(1.4, String, N) The Java resource name of a properties file containing one or more task definitions. This is identical to the
file
attribute, except it uses aClassLoader
to locate the properties file.
The name
and classname
attributes are required unless the file
or
resource
attributes are specified.
Content
- 0,1 nested
<classpath>
elements (all) May be used in place of the
classpath
attribute.
Example Usage
Defines a custom task that can then be used throughout a project:
<taskdef name="mycodegen" classname="com.foobar.tasks.MyCodeGen"/>
Get Ant: The Definitive Guide 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.