Class TryTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
ise.antelope.tasks.TryTask
All Implemented Interfaces:
Cloneable, org.apache.tools.ant.TaskContainer

public class TryTask extends org.apache.tools.ant.Task implements org.apache.tools.ant.TaskContainer
Try is a container task - it can contain other Ant tasks. The nested tasks are simply executed in sequence. Try's primary use is to support the try/catch-like execution of a set of tasks. If any of the child tasks fail (that is, they throw a build exception), the exception is caught and the build can continue. This is sometimes useful for tasks that can fail, but it isn't necessary to fail the build if they do. For example, the "mail" task may fail if the server is unavailable, but not sending the message may not be critical to the build continuing.
Since:
Ant 1.5
Version:
$Revision: 6 $
  • Field Summary

    Fields inherited from class org.apache.tools.ant.Task

    target, taskName, taskType, wrapper

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    void
    addTask(org.apache.tools.ant.Task task)
    Add a nested task to Try.
    void
    Try to execute all tasks.
    void
    make sure dependent tasks are loaded
    void
    Override maybeConfigure in a way that leaves the nested tasks unconfigured until they get executed.
    void
    setBreak(boolean b)
    A try block may contain several tasks.
    void
    the error message of the exception can be stored as a property
    void
    setPrintmessage(boolean b)
    If printstacktrace is set to true, this is ignored as the error message is printed as part of the stack trace.
    void
    setPrintstacktrace(boolean b)
    Default is to not print the stack trace.
    void
    the stack trace can be stored as a property

    Methods inherited from class org.apache.tools.ant.Task

    bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TryTask

      public TryTask()
  • Method Details

    • init

      public void init()
      make sure dependent tasks are loaded
      Overrides:
      init in class org.apache.tools.ant.Task
    • maybeConfigure

      public void maybeConfigure() throws org.apache.tools.ant.BuildException
      Override maybeConfigure in a way that leaves the nested tasks unconfigured until they get executed.
      Overrides:
      maybeConfigure in class org.apache.tools.ant.Task
      Throws:
      org.apache.tools.ant.BuildException - Description of Exception
      Since:
      Ant 1.5
    • addTask

      public void addTask(org.apache.tools.ant.Task task)
      Add a nested task to Try.
      Specified by:
      addTask in interface org.apache.tools.ant.TaskContainer
      Parameters:
      task - Nested task to try to execute
    • addCatch

      public void addCatch(CatchTask task)
    • addFinally

      public void addFinally(FinallyTask task)
    • setBreak

      public void setBreak(boolean b)
      A try block may contain several tasks. This parameter determines whether the block should continue executing tasks following a failed task. The default is false, and the try block will exit on the first failure. Note that if set to false and more than one task fails, the "catch" target will execute for each failed task.
      Parameters:
      b - if set to false, the try block will execute all tasks in the block, regardless of failure of an individual task.
    • setPrintmessage

      public void setPrintmessage(boolean b)
      If printstacktrace is set to true, this is ignored as the error message is printed as part of the stack trace. Default is to print the message.
      Parameters:
      b - Should the error message of a failed task be logged?
    • setMessageproperty

      public void setMessageproperty(String name)
      the error message of the exception can be stored as a property
    • setPrintstacktrace

      public void setPrintstacktrace(boolean b)
      Default is to not print the stack trace.
      Parameters:
      b - Should the stack trace of a failed task be logged?
    • setStacktraceproperty

      public void setStacktraceproperty(String name)
      the stack trace can be stored as a property
    • execute

      public void execute() throws org.apache.tools.ant.BuildException
      Try to execute all tasks.
      Overrides:
      execute in class org.apache.tools.ant.Task
      Throws:
      org.apache.tools.ant.BuildException - Description of Exception