From 237c7fc4c3dfbc67b9dc39e3afa657d205310eff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Mat=C3=A8rne?=
org.apache.tools.ant.Task
or another class that was designed to be extended.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 of the name in uppercase, and the rest in
-
lowercase*. That is, to support an attribute named
file
you create a method setFile
.
Depending on the type of the argument, Ant will perform some
conversions for you, see below.parallel
), your
- class must implement the interface
- org.apache.tools.ant.TaskContainer
. If you do so, your
- task can not support any other nested elements. See
- below.public void addText(String)
-method. Note that Ant does not expand properties on
-the text it passes to the task.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 (or
-addConfigured) 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 (addConfigured) method
-must begin with add
(addConfigured
),
-followed by the element name. For a more complete discussion see
-below.public void execute
method, with no arguments, that
-throws a BuildException
. This method implements the task
-itself.parallel
), your
+ class must implement the interface
+ org.apache.tools.ant.TaskContainer
. If you do so, your
+ task can not support any other nested elements. See
+ below.
+
+ public void addText(String)
+ method. Note that Ant does not expand properties on
+ the text it passes to the task.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 (or
+ addConfigured) 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 (addConfigured) method
+ must begin with add
(addConfigured
),
+ followed by the element name. For a more complete discussion see
+ below.public void execute
method, with no arguments, that
+ throws a BuildException
. This method implements the task
+ itself.
@@ -261,7 +261,7 @@ handled.
<typedef>
you have two options.
The TaskContainer
consists of a single method,
@@ -382,8 +383,7 @@ invoke perform
on these instances instead of
Let's write our own task, which prints a message on the
System.out
stream.
-The
-task has one attribute, called message
.
message
.
+package com.mydomain; @@ -430,6 +430,7 @@ public class MyVeryOwnTask extends Task { </project>
<taskdef>
declaration inside a target
@@ -467,42 +468,41 @@ package. Then you can use it as if it were a built-in task.
Ant is capable of generating build events as it performs the tasks necessary to build a project. +
Ant is capable of generating build events as it performs the tasks necessary to build a project. Listeners can be attached to Ant to receive these events. This capability could be used, for example, to connect Ant to a GUI or to integrate Ant with an IDE. -
+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
If the build file invokes another build file via <ant>
or <subant>
or uses <antcall>
, you are creating a
+
If the build file invokes another build file via
+<ant>
or
+<subant>
or uses
+<antcall>
, you are creating a
new Ant "project" that will send target and task level events of its
own but never sends build started/finished events. Ant 1.6.2
introduces an extension of the BuildListener interface named
SubBuildListener that will receive two new events for
If you are interested in those events, all you need to do is to implement the new interface instead of BuildListener (and register the listener, of course).
--If you wish to attach a listener from the command line you may use the +
If you wish to attach a listener from the command line you may use the
-listener
option. For example:
ant -listener org.apache.tools.ant.XmlLogger@@ -515,8 +515,7 @@ these streams is redirected by Ant's core to the build event system. Accessing t streams can cause an infinite loop in Ant. Depending on the version of Ant, this will either cause the build to terminate or the Java VM to run out of Stack space. A logger, also, may not access System.out and System.err directly. It must use the streams with which it has -been configured. - +been configured.Note2: All methods of a BuildListener except for the "Build Started" and "Build Finished" events may occur on several threads @@ -526,20 +525,19 @@ been configured.
Source code integration
-The other way to extend Ant through Java is to make changes to existing tasks, which is positively encouraged. +The other way to extend Ant through Java is to make changes to existing tasks, which is positively encouraged. Both changes to the existing source and new tasks can be incorporated back into the Ant codebase, which -benefits all users and spreads the maintenance load around. -
+benefits all users and spreads the maintenance load around.
-Please consult the -Getting Involved pages on the Jakarta web site +Please consult the +Getting Involved pages on the Apache web site for details on how to fetch the latest source and how to submit changes for reincorporation into the -source tree. -
-Ant also has some +source tree.
+ +Ant also has some task guidelines which provides some advice to people developing and testing tasks. Even if you intend to -keep your tasks to yourself, you should still read this as it should be informative. +keep your tasks to yourself, you should still read this as it should be informative.