From fd6adf10c60b217f6ee09aa7470b19042ef96981 Mon Sep 17 00:00:00 2001
From: "Arnout J. Kuiper" Version 1.0.7 - 2000/02/28 Version 1.0.8 - 2000/03/04
Table of Contents
@@ -2093,12 +2093,17 @@ it encounters for a specific task in the buildfile, before it executes is.
Let's write our own task, that prints a message on the System.out stream. The task has one attribute called "message".
- public class MyVeryOwnTask extends Task {
+ package com.mydomain;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class MyVeryOwnTask extends Task {
private String msg;
// The method executing the task
public void execute() throws BuildException {
- System.out.println(message);
+ System.out.println(msg);
}
// The setter for the "message" attribute
@@ -2118,13 +2123,15 @@ task has one attribute called "message".
Example
- <project name="TaskTest" default="test" basedir=".">
+ <?xml version="1.0"?>
+
+<project name="OwnTaskExample" default="main" basedir=".">
<target name="init">
<taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/>
</target>
- <target name="test">
- <mytask myattr="wombat" />
+ <target name="main" depends="init">
+ <mytask message="Hello World! MyVeryOwnTask works!" />
</target>
</project>