@@ -147,6 +147,7 @@ public class MyVeryOwnTask extends Task {
<li>Use your task in the rest of the buildfile.</li>
</ol>
<h3>Example</h3>
<blockquote>
<pre>
@@ -161,6 +162,37 @@ public class MyVeryOwnTask extends Task {
</project>
</pre>
</blockquote>
<h3>Example 2</h3>
To use a task directly from the buildfile which created it, place the
<code><taskdef></code> declaration inside a target
<i>after the compilation</i>. Use the <code>classpath</code> attribute of
<code><taskdef></code> to point to where the code has just been
compiled.
<blockquote>
<pre>
<?xml version="1.0"?>
<project name="OwnTaskExample2" default="main" basedir=".">
<target name="build" >
<mkdir dir="build"/>
<javac srcdir="source" destdir="build"/>
</target>
<target name="declare" depends="build">
<taskdef name="mytask"
classname="com.mydomain.MyVeryOwnTask"
classpath="build"/>
</target>
<target name="main" depends="declare">
<mytask message="Hello World! MyVeryOwnTask works!"/>
</target>
</project>
</pre>
</blockquote>
<p>Another way to add a task (more permanently), is to add the task name and
implementing class name to the <code>default.properties</code> file in the
<code>org.apache.tools.ant.taskdefs</code>