Methods Summary |
---|
public final void | bindToOwner(org.apache.tools.ant.Task owner)Bind a task to another; use this when configuring a newly created
task to do work on behalf of another.
Project, OwningTarget, TaskName, Location and Description are all copied
Important: this method does not call {@link Task#init()}.
If you are creating a task to delegate work to, call {@link Task#init()}
to initialize it.
setProject(owner.getProject());
setOwningTarget(owner.getOwningTarget());
setTaskName(owner.getTaskName());
setDescription(owner.getDescription());
setLocation(owner.getLocation());
setTaskType(owner.getTaskType());
|
public void | execute()Called by the project to let the task do its work. This method may be
called more than once, if the task is invoked more than once.
For example,
if target1 and target2 both depend on target3, then running
"ant target1 target2" will run all tasks in target3 twice.
|
public Target | getOwningTarget()Returns the container target of this task.
return target;
|
private UnknownElement | getReplacement()Creates an UnknownElement that can be used to replace this task.
Once this has been created once, it is cached and returned by
future calls.
if (replacement == null) {
replacement = new UnknownElement(taskType);
replacement.setProject(getProject());
replacement.setTaskType(taskType);
replacement.setTaskName(taskName);
replacement.setLocation(location);
replacement.setOwningTarget(target);
replacement.setRuntimeConfigurableWrapper(wrapper);
wrapper.setProxy(replacement);
replaceChildren(wrapper, replacement);
target.replaceChild(this, replacement);
replacement.maybeConfigure();
}
return replacement;
|
public RuntimeConfigurable | getRuntimeConfigurableWrapper()Returns the wrapper used for runtime configuration.
if (wrapper == null) {
wrapper = new RuntimeConfigurable(this, getTaskName());
}
return wrapper;
|
public java.lang.String | getTaskName()Returns the name to use in logging messages.
return taskName;
|
public java.lang.String | getTaskType()Return the type of task.
return taskType;
|
protected RuntimeConfigurable | getWrapper()Return the runtime configurable structure for this task.
return wrapper;
|
protected void | handleErrorFlush(java.lang.String output)Handles an error line by logging it with the WARN priority.
handleErrorOutput(output);
|
protected void | handleErrorOutput(java.lang.String output)Handles an error output by logging it with the WARN priority.
log(output, Project.MSG_WARN);
|
protected void | handleFlush(java.lang.String output)Handles output by logging it with the INFO priority.
handleOutput(output);
|
protected int | handleInput(byte[] buffer, int offset, int length)Handle an input request by this task.
return getProject().defaultInput(buffer, offset, length);
|
protected void | handleOutput(java.lang.String output)Handles output by logging it with the INFO priority.
log(output, Project.MSG_INFO);
|
public void | init()Called by the project to let the task initialize properly.
The default implementation is a no-op.
|
protected final boolean | isInvalid()Has this task been marked invalid?
return invalid;
|
public void | log(java.lang.String msg)Logs a message with the default (INFO) priority.
log(msg, Project.MSG_INFO);
|
public void | log(java.lang.String msg, int msgLevel)Logs a message with the given priority. This delegates
the actual logging to the project.
if (getProject() != null) {
getProject().log(this, msg, msgLevel);
} else {
super.log(msg, msgLevel);
}
|
public void | log(java.lang.Throwable t, int msgLevel)Logs a message with the given priority. This delegates
the actual logging to the project.
if (t != null) {
log(t.getMessage(), t, msgLevel);
}
|
public void | log(java.lang.String msg, java.lang.Throwable t, int msgLevel)Logs a message with the given priority. This delegates
the actual logging to the project.
if (getProject() != null) {
getProject().log(this, msg, t, msgLevel);
} else {
super.log(msg, msgLevel);
}
|
final void | markInvalid()Marks this task as invalid. Any further use of this task
will go through a replacement with the updated definition.
invalid = true;
|
public void | maybeConfigure()Configures this task - if it hasn't been done already.
If the task has been invalidated, it is replaced with an
UnknownElement task which uses the new definition in the project.
if (!invalid) {
if (wrapper != null) {
wrapper.maybeConfigure(getProject());
}
} else {
getReplacement();
}
|
public final void | perform()Performs this task if it's still valid, or gets a replacement
version and performs that otherwise.
Performing a task consists of firing a task started event,
configuring the task, executing it, and then firing task finished
event. If a runtime exception is thrown, the task finished event
is still fired, but with the exception as the cause.
if (!invalid) {
getProject().fireTaskStarted(this);
Throwable reason = null;
try {
maybeConfigure();
DispatchUtils.execute(this);
} catch (BuildException ex) {
if (ex.getLocation() == Location.UNKNOWN_LOCATION) {
ex.setLocation(getLocation());
}
reason = ex;
throw ex;
} catch (Exception ex) {
reason = ex;
BuildException be = new BuildException(ex);
be.setLocation(getLocation());
throw be;
} catch (Error ex) {
reason = ex;
throw ex;
} finally {
getProject().fireTaskFinished(this, reason);
}
} else {
UnknownElement ue = getReplacement();
Task task = ue.getTask();
task.perform();
}
|
public void | reconfigure()Force the task to be reconfigured from its RuntimeConfigurable.
if (wrapper != null) {
wrapper.reconfigure(getProject());
}
|
private void | replaceChildren(RuntimeConfigurable wrapper, UnknownElement parentElement)Recursively adds an UnknownElement instance for each child
element of replacement.
Enumeration e = wrapper.getChildren();
while (e.hasMoreElements()) {
RuntimeConfigurable childWrapper =
(RuntimeConfigurable) e.nextElement();
UnknownElement childElement =
new UnknownElement(childWrapper.getElementTag());
parentElement.addChild(childElement);
childElement.setProject(getProject());
childElement.setRuntimeConfigurableWrapper(childWrapper);
childWrapper.setProxy(childElement);
replaceChildren(childWrapper, childElement);
}
|
public void | setOwningTarget(Target target)Sets the target container of this task.
this.target = target;
|
public void | setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)Sets the wrapper to be used for runtime configuration.
This method should be used only by the ProjectHelper and Ant internals.
It is public to allow helper plugins to operate on tasks, normal tasks
should never use it.
this.wrapper = wrapper;
|
public void | setTaskName(java.lang.String name)Sets the name to use in logging messages.
this.taskName = name;
|
public void | setTaskType(java.lang.String type)Sets the name with which the task has been invoked.
this.taskType = type;
|