From c343aaa8da806681107589ff2536b003af51eefe Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sun, 14 Oct 2001 04:39:49 +0000 Subject: [PATCH] Text + example of how to use a task in the file it is compiled. Keeping silent on taskdef's property file loading functionality so that people dont start using it just before it gets taken away. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269793 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/develop.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/manual/develop.html b/docs/manual/develop.html index 8b6d327dd..c9c28622b 100644 --- a/docs/manual/develop.html +++ b/docs/manual/develop.html @@ -147,6 +147,7 @@ public class MyVeryOwnTask extends Task {
  • Use your task in the rest of the buildfile.
  • +

    Example

    @@ -161,6 +162,37 @@ public class MyVeryOwnTask extends Task {
     </project>
     
    +

    Example 2

    +To use a task directly from the buildfile which created it, place the +<taskdef> declaration inside a target +after the compilation. Use the classpath attribute of +<taskdef> to point to where the code has just been +compiled. +
    +
    +<?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>
    +
    +
    + +

    Another way to add a task (more permanently), is to add the task name and implementing class name to the default.properties file in the org.apache.tools.ant.taskdefs