From d3bb8dc2f627e27c2ae1fe8d72955c56d77c2c86 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig Version 1.1 - 2000/07/18 Version 1.2 - 2000/07/26
Table of Contents
@@ -41,7 +41,7 @@
If you prefer the source edition, you can download Ant from
@@ -3211,134 +3211,6 @@ in the ${dist}
directory. Files/directories with the names my
and
todo.html
are excluded.
To use build events you need to create an ant Project
object. You can then call the
-addBuildListener
method to add your listener to the project. Your listener must implement
-the org.apache.tools.antBuildListener
interface. The listener will receive BuildEvents
-for the following events
-
--will run ant with a listener which generates an XML representaion of the build progress. This -listener is included with ant as is the default listener which generates the logging to standard -output. - - -ant -listener org.apache.tools.ant.XmlLogger-
It is very easy to write your own task:
-org.apache.tools.ant.Task
.public void
method that takes a single argument. The
- name of the method must begin with "set", followed by the
- attribute name, with the first character in uppercase, and the rest in
- lowercase. The type of the attribute can be String
, any
- primitive type, Class
, File
(in which case the
- value of the attribute is interpreted relative to the project's basedir)
- or any other type that has a constructor with a single String
- argumentpublic void
- addText(String)
method.public
method that takes no arguments and returns
- an Object type. The name of the create method must begin with
- "create", followed by the element name. An add method must be
- a public void
method that takes a single argument of an
- Object type with a no argument constructor. The name of the add method
- must begin with "add", followed by the element name.
- public void execute
method, with no arguments, that
- throws a BuildException
. This method implements the task
- itself.It is important to know that Ant first calls the setters for the attributes -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".
---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(msg); - } - - // The setter for the "message" attribute - public void setMessage(String msg) { - this.msg = msg; - } -}-
It's really this simple;-)
-Adding your task to the system is rather simple too:
---<?xml version="1.0"?> - -<project name="OwnTaskExample" default="main" basedir="."> - <target name="init"> - <taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/> - </target> - - <target name="main" depends="init"> - <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
-package. Then you can use it as if it were a built in task.
There is an online FAQ for Ant at jakarta.apache.org. This -FAQ is interactive, which means you can ask and answer questions -online.
-One of the questions poping up quite often is "Is there a DTD for -buildfiles?". Please refer to the FAQ for an answer.
-The FAQ contains lists of known custom tasks that don't ship with -Ant and projects that use Ant. Feel free to add your own task or project -there.
-To provide feedback on this software, please subscribe to the Ant Development -Mail List (ant-dev-subscribe@jakarta.apache.org)
-Copyright © 2000 Apache Software Foundation. All rights -Reserved.
-+None yet available
To use build events you need to create an ant Project
object. You can then call the
+addBuildListener
method to add your listener to the project. Your listener must implement
+the org.apache.tools.antBuildListener
interface. The listener will receive BuildEvents
+for the following events
+
++will run ant with a listener which generates an XML representaion of the build progress. This +listener is included with ant as is the default listener which generates the logging to standard +output. + + +ant -listener org.apache.tools.ant.XmlLogger+
It is very easy to write your own task:
+org.apache.tools.ant.Task
.public void
method that takes a single argument. The
+ name of the method must begin with "set", followed by the
+ attribute name, with the first character in uppercase, and the rest in
+ lowercase. The type of the attribute can be String
, any
+ primitive type, Class
, File
(in which case the
+ value of the attribute is interpreted relative to the project's basedir)
+ or any other type that has a constructor with a single String
+ argumentpublic void
+ addText(String)
method.public
method that takes no arguments and returns
+ an Object type. The name of the create method must begin with
+ "create", followed by the element name. An add method must be
+ a public void
method that takes a single argument of an
+ Object type with a no argument constructor. The name of the add method
+ must begin with "add", followed by the element name.
+ public void execute
method, with no arguments, that
+ throws a BuildException
. This method implements the task
+ itself.It is important to know that Ant first calls the setters for the attributes +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".
+++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(msg); + } + + // The setter for the "message" attribute + public void setMessage(String msg) { + this.msg = msg; + } +}+
It's really this simple;-)
+Adding your task to the system is rather simple too:
+++<?xml version="1.0"?> + +<project name="OwnTaskExample" default="main" basedir="."> + <target name="init"> + <taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/> + </target> + + <target name="main" depends="init"> + <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
+package. Then you can use it as if it were a built in task.
There is an online FAQ for Ant at jakarta.apache.org. This +FAQ is interactive, which means you can ask and answer questions +online.
+One of the questions poping up quite often is "Is there a DTD for +buildfiles?". Please refer to the FAQ for an answer.
+To provide feedback on this software, please subscribe to the Ant User +Mail List (ant-user-subscribe@jakarta.apache.org)
+If you want to contribute to Ant or stay current with the latest +development, join the Ant Development Mail List (ant-dev-subscribe@jakarta.apache.org)
+Copyright © 2000 Apache Software Foundation. All rights +Reserved.
+