Package ise.antelope.tasks
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addFinally
(FinallyTask task) void
addTask
(org.apache.tools.ant.Task task) Add a nested task to Try.void
execute()
Try to execute all tasks.void
init()
make sure dependent tasks are loadedvoid
OverridemaybeConfigure
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
setMessageproperty
(String name) the error message of the exception can be stored as a propertyvoid
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
setStacktraceproperty
(String name) the stack trace can be stored as a propertyMethods 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
-
Constructor Details
-
TryTask
public TryTask()
-
-
Method Details
-
init
public void init()make sure dependent tasks are loaded- Overrides:
init
in classorg.apache.tools.ant.Task
-
maybeConfigure
public void maybeConfigure() throws org.apache.tools.ant.BuildExceptionOverridemaybeConfigure
in a way that leaves the nested tasks unconfigured until they get executed.- Overrides:
maybeConfigure
in classorg.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 interfaceorg.apache.tools.ant.TaskContainer
- Parameters:
task
- Nested task to try to execute
-
addCatch
-
addFinally
-
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
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
the stack trace can be stored as a property -
execute
public void execute() throws org.apache.tools.ant.BuildExceptionTry to execute all tasks.- Overrides:
execute
in classorg.apache.tools.ant.Task
- Throws:
org.apache.tools.ant.BuildException
- Description of Exception
-