From 237c7fc4c3dfbc67b9dc39e3afa657d205310eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mat=C3=A8rne?= Date: Thu, 28 May 2015 08:25:47 +0200 Subject: [PATCH] Manual:develop: there is no Jakarta any more --- manual/develop.html | 116 ++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 59 deletions(-) diff --git a/manual/develop.html b/manual/develop.html index 774961ca8..ed06d3011 100644 --- a/manual/develop.html +++ b/manual/develop.html @@ -30,43 +30,43 @@
  1. Create a Java class that extends org.apache.tools.ant.Task or another class that was designed to be extended.
  2. +
  3. For each attribute, write a setter method. The setter method must be a 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.
  4. If your task shall contain other tasks as nested elements (like - 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.
  5. - -
  6. If the task should support character data (text nested between the -start end end tags), write a public void addText(String) -method. Note that Ant does not expand properties on -the text it passes to the task.
  7. - -
  8. For each nested element, write a create, add or -addConfigured method. A create method must be a -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.
  9. - -
  10. Write a public void execute method, with no arguments, that -throws a BuildException. This method implements the task -itself.
  11. + 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. + +
  12. If the task should support character data (text nested between the + start end end tags), write a public void addText(String) + method. Note that Ant does not expand properties on + the text it passes to the task.
  13. + +
  14. For each nested element, write a create, add or + addConfigured method. A create method must be a + 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.
  15. + +
  16. Write a public void execute method, with no arguments, that + throws a BuildException. This method implements the task + itself.

@@ -261,7 +261,7 @@ handled.

the methods will be called, but we don't know which, this depends on the implementation of your Java virtual machine.

-

Nested Types

+

Nested Types

If your task needs to nest an arbitrary type that has been defined using <typedef> you have two options.
    @@ -361,6 +361,7 @@ public class Sample { </copy> +

    TaskContainer

    The TaskContainer consists of a single method, @@ -382,8 +383,7 @@ invoke perform on these instances instead of

    Example

    Let's write our own task, which prints a message on the System.out stream. -The -task has one attribute, called message.

    +The task has one attribute, called message.

     package com.mydomain;
    @@ -430,6 +430,7 @@ public class MyVeryOwnTask extends Task {
     </project>
     
    +

    Example 2

    To use a task directly from the buildfile which created it, place the <taskdef> declaration inside a target @@ -467,42 +468,41 @@ package. Then you can use it as if it were a built-in task.


    Build Events

    -

    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

    +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.