|
|
@@ -17,7 +17,7 @@ |
|
|
|
<li>Sam Ruby (<a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>)</li> |
|
|
|
</ul> |
|
|
|
|
|
|
|
<p>Version 1.0.7 - 2000/02/28</p> |
|
|
|
<p>Version 1.0.8 - 2000/03/04</p> |
|
|
|
|
|
|
|
<hr> |
|
|
|
<h2>Table of Contents</h2> |
|
|
@@ -2093,12 +2093,17 @@ it encounters for a specific task in the buildfile, before it executes is.</p> |
|
|
|
<p>Let's write our own task, that prints a message on the System.out stream. The |
|
|
|
task has one attribute called "message".</p> |
|
|
|
<blockquote> |
|
|
|
<pre>public class MyVeryOwnTask extends Task { |
|
|
|
<pre>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".</p> |
|
|
|
</ol> |
|
|
|
<h3>Example</h3> |
|
|
|
<blockquote> |
|
|
|
<pre><project name="TaskTest" default="test" basedir="."> |
|
|
|
<pre><?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> |
|
|
|
</pre> |
|
|
|