·  ANT – Tags – <taskdef/> – Define name/classname pairs in separate file

 

- Info:

  - Each line in tasks.properties defines task name and classname which implements that task.

 

- Example:

  - Create ANT Script Test.xml

  - Create JAVA Console Application D:\Temp\ANT\Test.java

 

    Test.xml

    <?xml version="1.0" encoding="UTF-8"?>

    

    <project name="MyAntProject" default="default" basedir=".">

    

      <taskdef  resource  = "tasks.properties"

                classpath = ."/>

          

       <target name="default">

         <taskHello par1="Hello world!" />

       </target>  

    

    </project>

 

    Test.java

    import org.apache.tools.ant.Task;

    import org.apache.tools.ant.BuildException;

    

    public class Test extends Task {

      

      private String par1;

 

      public  void   setPar1(String in) { par1 = in; } 

        

      public void execute() throws BuildException {

        System.out.println("Task called with:" + par1);   

      }

      

    }

    

    tasks.properties

    taskHello = Test

 

- Test:

  - Start MSDOS

  - cd D:\Temp\ANT

  - javac -cp D:\Installed\Programming\apache-ant-1.7.1\lib\ant.jar Test.java

  - ant.bat -buildfile Test.xml