diff --git a/WHATSNEW b/WHATSNEW index eef76efc8..62cdff51a 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -35,7 +35,7 @@ behavior has been dropped. Other changes: -------------- -* New tasks: antstructure, cab, execon, ftp, genkey, junit, sql, javacc, jjtree, starteam. +* New tasks: antstructure, cab, execon, fail, ftp, genkey, junit, sql, javacc, jjtree, starteam. * New tasks mparse pending documentation. diff --git a/docs/index.html b/docs/index.html index b3b79bd5d..e927b3409 100644 --- a/docs/index.html +++ b/docs/index.html @@ -836,6 +836,7 @@ same patterns as the example before.

  • Echo
  • Exec
  • ExecOn
  • +
  • Fail
  • Filter
  • FixCRLF
  • GenKey
  • @@ -1646,11 +1647,47 @@ files below /tmp not ending in .txt and all files of the FileSet with id other.files to the command line.


    +

    Fail

    +

    Description

    +

    Exits the current build (just throwing a BuildException), optionally printing additional information.

    +

    Parameters

    + + + + + + + + + + + +
    AttributeDescriptionRequired
    messageA message giving further information on why the build exitedNo
    +

    Examples

    +
      <fail/>
    +

    will exit the current build with no further information given. +

    +BUILD FAILED
    +
    +build.xml:4: No message
    +
    +

    +
      <fail message="Something wrong here."/>
    +

    will exit the current build and print something like the following to whereever +your output goes: +

    +BUILD FAILED
    +
    +build.xml:4: Something wrong here.
    +
    +

    +

    Filter

    Description

    Sets a token filter for this project. Token filters are used by all tasks that perform file copying operations through the Project commodity methods.

    Note: the token string must not contain the separators chars (@).

    +

    Parameters

    diff --git a/src/main/org/apache/tools/ant/taskdefs/Exit.java b/src/main/org/apache/tools/ant/taskdefs/Exit.java new file mode 100644 index 000000000..8dfd60a12 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/Exit.java @@ -0,0 +1,79 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package org.apache.tools.ant.taskdefs; + +import org.apache.tools.ant.*; + +/** + * Just exit the active build, giving an additional message + * if available. + * + * @author Nico Seessle + */ +public class Exit extends Task { + private String message; + + public void setMessage(String value) { + this.message = value; + } + + public void execute() throws BuildException { + if (message != null && message.length() > 0) { + throw new BuildException(message); + } else { + throw new BuildException("No message"); + } + } +} diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index 832225376..182294e88 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -41,6 +41,7 @@ execon=org.apache.tools.ant.taskdefs.ExecuteOn antcall=org.apache.tools.ant.taskdefs.CallTarget sql=org.apache.tools.ant.taskdefs.SQLExec mail=org.apache.tools.ant.taskdefs.SendEmail +fail=org.apache.tools.ant.taskdefs.Exit # optional tasks script=org.apache.tools.ant.taskdefs.optional.Script