Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
public abstract class Task
extends ProjectComponent
Project.createTask(String)
Field Summary | |
protected String |
|
protected Location |
|
protected Target |
|
protected String |
|
protected String |
|
protected RuntimeConfigurable |
|
Fields inherited from class org.apache.tools.ant.ProjectComponent | |
project |
Constructor Summary | |
|
Method Summary | |
void |
|
String |
|
Location |
|
Target |
|
RuntimeConfigurable |
|
String |
|
String |
|
protected RuntimeConfigurable |
|
protected void |
|
protected void |
|
protected void |
|
protected int |
|
protected void |
|
void |
|
protected boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class org.apache.tools.ant.ProjectComponent | |
getProject , log , log , setProject |
protected String description
Deprecated. You should not be accessing this variable directly.
Description of this task, if any.
protected Location location
Deprecated. You should not be accessing this variable directly. Please use the
getLocation()
method.Location within the build file of this task definition.
protected Target target
Deprecated. You should not be accessing this variable directly. Please use the
getOwningTarget()
method.Target this task belongs to, if any.
protected String taskName
Deprecated. You should not be accessing this variable directly. Please use the
getTaskName()
method.Name of this task to be used for logging purposes. This defaults to the same as the type, but may be overridden by the user. For instance, the name "java" isn't terribly descriptive for a task used within another task - the outer task code can probably provide a better one.
protected String taskType
Deprecated. You should not be accessing this variable directly. Please use the
getTaskType()
method.Type of this task.
protected RuntimeConfigurable wrapper
Deprecated. You should not be accessing this variable directly. Please use the
getWrapper()
method.Wrapper for this object, used to configure it at runtime.
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.
- Throws:
BuildException
- if something goes wrong with the build
public String getDescription()
Returns the description of the current action.
- Returns:
- the description of the current action, or
null
if no description is available.
public Location getLocation()
Returns the file/location where this task was defined.
- Returns:
- the file/location where this task was defined. Should not return
null
. Location.UNKNOWN_LOCATION is used for unknown locations.
- See Also:
Location.UNKNOWN_LOCATION
public Target getOwningTarget()
Returns the container target of this task.
- Returns:
- The target containing this task, or
null
if this task is a top-level task.
public RuntimeConfigurable getRuntimeConfigurableWrapper()
Returns the wrapper used for runtime configuration.
- Returns:
- the wrapper used for runtime configuration. This method will generate a new wrapper (and cache it) if one isn't set already.
public String getTaskName()
Returns the name to use in logging messages.
- Returns:
- the name to use in logging messages.
public String getTaskType()
Return the type of task
- Returns:
- the type of task
protected RuntimeConfigurable getWrapper()
Return the runtime configurable structure for this task
- Returns:
- the runtime structure for this task
protected void handleErrorFlush(String output)
Handles an error line by logging it with the WARN priority.
- Parameters:
output
- The error output to log. Should not benull
.
- Since:
- Ant 1.5.2
protected void handleErrorOutput(String output)
Handles an error output by logging it with the WARN priority.
- Parameters:
output
- The error output to log. Should not benull
.
protected void handleFlush(String output)
Handles output by logging it with the INFO priority.
- Parameters:
output
- The output to log. Should not benull
.
- Since:
- Ant 1.5.2
protected int handleInput(byte[] buffer, int offset, int length) throws IOException
Handle an input request by this task
- Parameters:
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
- Returns:
- the number of bytes read
- Since:
- Ant 1.6
protected void handleOutput(String output)
Handles output by logging it with the INFO priority.
- Parameters:
output
- The output to log. Should not benull
.
public void init() throws BuildException
Called by the project to let the task initialize properly. The default implementation is a no-op.
- Throws:
BuildException
- if something goes wrong with the build
protected final boolean isInvalid()
Has this task been marked invalid?
- Returns:
- true if this task is no longer valid. A new task should be configured in this case.
- Since:
- Ant 1.5
public void log(String msg)
Logs a message with the default (INFO) priority.
- Overrides:
- log in interface ProjectComponent
- Parameters:
msg
- The message to be logged. Should not benull
.
public void log(String msg, int msgLevel)
Logs a message with the given priority. This delegates the actual logging to the project.
- Overrides:
- log in interface ProjectComponent
- Parameters:
msg
- The message to be logged. Should not benull
.msgLevel
- The message priority at which this message is to be logged.
public void maybeConfigure() throws BuildException
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.
- Throws:
BuildException
- if the task cannot be configured.
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.
public void reconfigure()
Force the task to be reconfigured from it's RuntimeConfigurable
public void setDescription(String desc)
Sets a description of the current action. This may be used for logging purposes.
- Parameters:
desc
- Description of the current action. May benull
, indicating that no description is available.
public void setLocation(Location location)
Sets the file/location where this task was defined.
- Parameters:
location
- The file/location where this task was defined. Should not benull
- use Location.UNKNOWN_LOCATION if the location isn't known.
- See Also:
Location.UNKNOWN_LOCATION
public void setOwningTarget(Target target)
Sets the target container of this task.
- Parameters:
target
- Target in whose scope this task belongs. May benull
, indicating a top-level task.
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.
- Parameters:
wrapper
- The wrapper to be used for runtime configuration. May benull
, in which case the next call to getRuntimeConfigurableWrapper will generate a new wrapper.
public void setTaskName(String name)
Sets the name to use in logging messages.
- Parameters:
name
- The name to use in logging messages. Should not benull
.
public void setTaskType(String type)
Sets the name with which the task has been invoked.
- Parameters:
type
- The name the task has been invoked as. Should not benull
.