public abstract class Task extends ProjectComponent
Project.createTask(java.lang.String)
Constructor and Description |
---|
Task()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
bindToOwner(Task owner)
Bind a task to another; use this when configuring a newly created
task to do work on behalf of another.
|
void |
execute()
Called by the project to let the task do its work.
|
Target |
getOwningTarget()
Returns the container target of this task.
|
RuntimeConfigurable |
getRuntimeConfigurableWrapper()
Returns the wrapper used for runtime configuration.
|
String |
getTaskName()
Returns the name to use in logging messages.
|
String |
getTaskType()
Return the type of task.
|
protected RuntimeConfigurable |
getWrapper()
Return the runtime configurable structure for this task.
|
protected void |
handleErrorFlush(String output)
Handles an error line by logging it with the WARN priority.
|
protected void |
handleErrorOutput(String output)
Handles an error output by logging it with the WARN priority.
|
protected void |
handleFlush(String output)
Handles output by logging it with the INFO priority.
|
protected int |
handleInput(byte[] buffer,
int offset,
int length)
Handle an input request by this task.
|
protected void |
handleOutput(String output)
Handles output by logging it with the INFO priority.
|
void |
init()
Called by the project to let the task initialize properly.
|
protected boolean |
isInvalid()
Has this task been marked invalid?
|
void |
log(String msg)
Logs a message with the default (INFO) priority.
|
void |
log(String msg,
int msgLevel)
Logs a message with the given priority.
|
void |
log(String msg,
Throwable t,
int msgLevel)
Logs a message with the given priority.
|
void |
log(Throwable t,
int msgLevel)
Logs a message with the given priority.
|
void |
maybeConfigure()
Configures this task - if it hasn't been done already.
|
void |
perform()
Performs this task if it's still valid, or gets a replacement
version and performs that otherwise.
|
void |
reconfigure()
Force the task to be reconfigured from its RuntimeConfigurable.
|
void |
setOwningTarget(Target target)
Sets the target container of this task.
|
void |
setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)
Sets the wrapper to be used for runtime configuration.
|
void |
setTaskName(String name)
Sets the name to use in logging messages.
|
void |
setTaskType(String type)
Sets the name with which the task has been invoked.
|
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
public final void bindToOwner(Task owner)
init()
.
If you are creating a task to delegate work to, call init()
to initialize it.owner
- owning targetpublic void execute() throws BuildException
BuildException
- if something goes wrong with the build.public Target getOwningTarget()
null
if
this task is a top-level task.public RuntimeConfigurable getRuntimeConfigurableWrapper()
public String getTaskName()
public String getTaskType()
protected RuntimeConfigurable getWrapper()
protected void handleErrorFlush(String output)
output
- The error output to log. Should not be null
.protected void handleErrorOutput(String output)
output
- The error output to log. Should not be null
.protected void handleFlush(String output)
output
- The output to log. Should not be null
.protected int handleInput(byte[] buffer, int offset, int length) throws IOException
buffer
- the buffer into which data is to be read.offset
- the offset into the buffer at which data is stored.length
- the amount of data to read.IOException
- if the data cannot be read.protected void handleOutput(String output)
output
- The output to log. Should not be null
.public void init() throws BuildException
BuildException
- if something goes wrong with the buildprotected final boolean isInvalid()
public void log(String msg)
log
in class ProjectComponent
msg
- The message to be logged. Should not be null
.public void log(String msg, int msgLevel)
log
in class ProjectComponent
msg
- The message to be logged. Should not be null
.msgLevel
- The message priority at which this message is to
be logged.public void log(String msg, Throwable t, int msgLevel)
msg
- The message to be logged. Should not be null
.t
- The exception to be logged. May be null
.msgLevel
- The message priority at which this message is to
be logged.public void log(Throwable t, int msgLevel)
t
- The exception to be logged. Should not be null
.msgLevel
- The message priority at which this message is to
be logged.public void maybeConfigure() throws BuildException
BuildException
- if the task cannot be configured.public final void perform()
public void reconfigure()
public void setOwningTarget(Target target)
target
- Target in whose scope this task belongs.
May be null
, indicating a top-level task.public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)
wrapper
- The wrapper to be used for runtime configuration.
May be null
, in which case the next call
to getRuntimeConfigurableWrapper will generate a new
wrapper.public void setTaskName(String name)
name
- The name to use in logging messages.
Should not be null
.public void setTaskType(String type)
type
- The name the task has been invoked as.
Should not be null
.