B.32 TaskdefTask
Prev | Appendix B. Core tasks | Next

## B.32 TaskdefTask

With the `TaskdefTask` you can import a user task into your buildfile.

Table B.34: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`classname` | `String` | The path to the class that defines the TaskClass. | n/a | Yes, unless the `file` attribute has been specified.
`name` | `String` | The name the task is available as after importing. If you specify "validate", for example, you can access the task imported here with `<validate>`. | n/a | Yes, unless the `file` attribute has been specified.
`file` | `String` | Name of the file to load definitions from. | n/a | No
`classpath` | `String` | The classpath to use when including classes. This is added to PHP's include_path. | n/a | No
`classpathref` | `String` | Reference to classpath to use when including classes. This is added to PHP's include_path. | n/a | No

### B.32.1 Examples

    <!-- Includes the Task named "ValidateHTMLTask" and makes it available by
         <validatehtml> -->
    <taskdef classname="user.tasks.ValidateHTMLTask" name="validatehtml" />

    <!-- Includes the Task "RebootTask" from "user/sometasks" somewhere inside
         the $PHP_CLASSPATH -->
    <taskdef classname="user.sometasks.RebootTask" name="reboot" />

    <!-- Includes all tasks from the property file. Each line in the property
    file defines a task in the format: name=path.to.Task -->
    <taskdef file="/path/to/mytasks.properties" />

NB: Taskdef now supports the PEAR-style naming convention to define and load tasks:

    <taskdef name="sampletask" classname="Dir_Subdir_SampleTask"/>

will load class `Dir_Subdir_SampleTask` from file `Dir/Subdir/SampleTask.php`.

### B.32.2 Supported Nested Tags

- `classpath`

Prev | Up | Next
B.31 SwitchTask | Home | B.33 TouchTask