Method from org.apache.tools.ant.Task Detail: |
public final void bindToOwner(Task owner) {
setProject(owner.getProject());
setOwningTarget(owner.getOwningTarget());
setTaskName(owner.getTaskName());
setDescription(owner.getDescription());
setLocation(owner.getLocation());
setTaskType(owner.getTaskType());
}
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 Task#init() .
If you are creating a task to delegate work to, call Task#init()
to initialize it. |
public void execute() throws BuildException {
}
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() {
return target;
}
Returns the container target of this task. |
public RuntimeConfigurable getRuntimeConfigurableWrapper() {
if (wrapper == null) {
wrapper = new RuntimeConfigurable(this, getTaskName());
}
return wrapper;
}
Returns the wrapper used for runtime configuration. |
public String getTaskName() {
return taskName;
}
Returns the name to use in logging messages. |
public String getTaskType() {
return taskType;
}
|
protected RuntimeConfigurable getWrapper() {
return wrapper;
}
Return the runtime configurable structure for this task. |
protected void handleErrorFlush(String output) {
handleErrorOutput(output);
}
Handles an error line by logging it with the WARN priority. |
protected void handleErrorOutput(String output) {
log(output, Project.MSG_WARN);
}
Handles an error output by logging it with the WARN priority. |
protected void handleFlush(String output) {
handleOutput(output);
}
Handles output by logging it with the INFO priority. |
protected int handleInput(byte[] buffer,
int offset,
int length) throws IOException {
return getProject().defaultInput(buffer, offset, length);
}
Handle an input request by this task. |
protected void handleOutput(String output) {
log(output, Project.MSG_INFO);
}
Handles output by logging it with the INFO priority. |
public void init() throws BuildException {
}
Called by the project to let the task initialize properly.
The default implementation is a no-op. |
protected final boolean isInvalid() {
return invalid;
}
Has this task been marked invalid? |
public void log(String msg) {
log(msg, Project.MSG_INFO);
}
Logs a message with the default (INFO) priority. |
public void log(String msg,
int msgLevel) {
if (getProject() != null) {
getProject().log(this, msg, msgLevel);
} else {
super.log(msg, msgLevel);
}
}
Logs a message with the given priority. This delegates
the actual logging to the project. |
public void log(Throwable t,
int msgLevel) {
if (t != null) {
log(t.getMessage(), t, msgLevel);
}
}
Logs a message with the given priority. This delegates
the actual logging to the project. |
public void log(String msg,
Throwable t,
int msgLevel) {
if (getProject() != null) {
getProject().log(this, msg, t, msgLevel);
} else {
super.log(msg, msgLevel);
}
}
Logs a message with the given priority. This delegates
the actual logging to the project. |
final void markInvalid() {
invalid = true;
}
Marks this task as invalid. Any further use of this task
will go through a replacement with the updated definition. |
public void maybeConfigure() throws BuildException {
if (!invalid) {
if (wrapper != null) {
wrapper.maybeConfigure(getProject());
}
} else {
getReplacement();
}
}
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. |
public final void perform() {
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();
}
}
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. |
public void reconfigure() {
if (wrapper != null) {
wrapper.reconfigure(getProject());
}
}
Force the task to be reconfigured from its RuntimeConfigurable. |
public void setOwningTarget(Target target) {
this.target = target;
}
Sets the target container of this task. |
public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper) {
this.wrapper = 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. |
public void setTaskName(String name) {
this.taskName = name;
}
Sets the name to use in logging messages. |
public void setTaskType(String type) {
this.taskType = type;
}
Sets the name with which the task has been invoked. |