From d3bb8dc2f627e27c2ae1fe8d72955c56d77c2c86 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 26 Jul 2000 10:51:18 +0000 Subject: [PATCH] Corrected the URL for nightly builds. Added reference to the ant-user mailing list. Removed pointer to the list of external tasks and known projects. I've moved the section on optional tasks to the position it should be, this makes the patch look a lot bigger than it actually is. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267842 13f79535-47bb-0310-9956-ffa450edef68 --- docs/index.html | 264 ++++++++++++++++++++++++------------------------ 1 file changed, 133 insertions(+), 131 deletions(-) diff --git a/docs/index.html b/docs/index.html index 83cad9f5c..bdeb4ee40 100644 --- a/docs/index.html +++ b/docs/index.html @@ -23,7 +23,7 @@
  • Sam Ruby (rubys@us.ibm.com)
  • -

    Version 1.1 - 2000/07/18

    +

    Version 1.2 - 2000/07/26


    Table of Contents

    @@ -41,7 +41,7 @@
  • Build Events
  • Writing your own task
  • FAQ, DTD, external resources -
  • License
  • +
  • License
  • Feedback
  • @@ -82,7 +82,7 @@ on.

    href="http://jakarta.apache.org/builds/ant/release/v1.1/bin/"> http://jakarta.apache.org/builds/ant/release/v1.1/bin/. If you like living on the edge, you can download the latest version from http://jakarta.apache.org/builds/tomcat/nightly/ant.zip.

    +href="http://jakarta.apache.org/builds/ant/nightly/">http://jakarta.apache.org/builds/ant/nightly/.

    Source edition

    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.


    -

    Build Events

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

    Writing your own task

    -

    It is very easy to write your own task:

    -
      -
    1. Create a Java class that extends org.apache.tools.ant.Task.
    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 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 - argument
    4. -
    5. If your task has enumerated attributes, you should consider using - a subclass of org.apache.tools.ant.types.EnumeratedAttribute as argument - to your setter method. See org.apache.tools.ant.taskdefs.FixCRLF for - an example.
    6. -
    7. If the task should support character data, write a public void - addText(String) method.
    8. -
    9. For each nested element, write a create or add 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 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. -
    10. Write a public void execute method, with no arguments, that - throws a BuildException. This method implements the task - itself.
    11. -
    -

    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:

    -
      -
    1. Make sure the class that implements your task is in the classpath when - starting Ant.
    2. -
    3. In your initialization target, add a taskdef task. This actually adds - your task to the system.
    4. -
    5. Use your task in the rest of the buildfile.
    6. -
    -

    Example

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

    -
    -

    FAQ, DTD, external resources

    -

    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.

    -

    Feedback

    -

    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.

    -

    Optional tasks