Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant
Class Task

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task

Direct Known Subclasses:
  AbstractCvsTask, AbstractMetamataTask, Ant, ANTLR, AntStarTeamCheckOut, AntStructure, Available, Basename, BorlandGenerateClient, BuildNumber, CallTarget, ChangeLogTask, ClearCase, Concat, Continuus, Copy, Copyfile, Coverage, CovMerge, CovReport, CVSPass, Definer, Deltree, Dirname, Echo, EchoProperties, EmailTask, Exec, ExecTask, Exit, Expand, Filter, FTP, GenerateKey, Get, Input, IPlanetEjbcTask, JarLibAvailableTask, JarLibDisplayTask, JarLibManifestTask, JarLibResolveTask, Java, JavaCC, Javadoc, Javah, JDBCTask, JDependTask, JJTree, JUnitTask, KeySubst, LoadFile, LoadProperties, ManifestTask, MatchingTask, Mkdir, MParse, MSVSS, P4Base, Pack, Parallel, Patch, PathConvert, Property, PropertyFile, Pvcs, Recorder, Rename, ReplaceRegExp, Rpm, Script, Sequential, ServerDeploy, SetProxy, SignJar, Sleep, SOS, SoundTask, SplashTask, StarTeamTask, TaskAdapter, TelnetTask, TempFile, Touch, Tstamp, UnknownElement, Unpack, UpToDate, VAJTask, WLRun, WLStop, WsdlToDotnet, XmlProperty, XMLResultAggregator, XMLValidateTask

public abstract class Task
extends ProjectComponent

Base class for all tasks. Use Project.createTask to create a new task instance rather than using this class directly for construction.

See Also:
  `Project.createTask(java.lang.String)`

Field Summary
`protected java.lang.String` | `description` Description of this task, if any.
`protected Location` | `location` Location within the build file of this task definition.
`protected Target` | `target` Target this task belongs to, if any.
`protected java.lang.String` | `taskName` Name of this task to be used for logging purposes.
`protected java.lang.String` | `taskType` Type of this task.
`protected RuntimeConfigurable` | `wrapper` Wrapper for this object, used to configure it at runtime.

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`Task()` Sole constructor.

Method Summary
`void` | `execute()` Called by the project to let the task do its work.
`java.lang.String` | `getDescription()` Returns the description of the current action.
`Location` | `getLocation()` Returns the file/location where this task was defined.
`Target` | `getOwningTarget()` Returns the container target of this task.
`RuntimeConfigurable` | `getRuntimeConfigurableWrapper()` Returns the wrapper used for runtime configuration.
`java.lang.String` | `getTaskName()` Returns the name to use in logging messages.
`protected void` | `handleErrorFlush(java.lang.String line)` Handles an error line by logging it with the INFO priority.
`protected void` | `handleErrorOutput(java.lang.String line)` Handles an error line by logging it with the INFO priority.
`protected void` | `handleFlush(java.lang.String line)` Handles a line of output by logging it with the INFO priority.
`protected void` | `handleOutput(java.lang.String line)` Handles a line of 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(java.lang.String msg)` Logs a message with the default (INFO) priority.
`void` | `log(java.lang.String msg, int msgLevel)` Logs a mesage 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` | `setDescription(java.lang.String desc)` Sets a description of the current action.
`void` | `setLocation(Location location)` Sets the file/location where this task was defined.
`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(java.lang.String name)` Sets the name to use in logging messages.

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### target

    protected Target target

  Target this task belongs to, if any.

### description

    protected java.lang.String description

  Description of this task, if any.

### location

    protected Location location

  Location within the build file of this task definition.

### taskName

    protected java.lang.String taskName

  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.

### taskType

    protected java.lang.String taskType

  Type of this task.

### wrapper

    protected RuntimeConfigurable wrapper

  Wrapper for this object, used to configure it at runtime.

Constructor Detail

### Task

    public Task()

  Sole constructor.

Method Detail

### setOwningTarget

    public void setOwningTarget(Target target)

  Sets the target container of this task.

  Parameters:
    `target` - Target in whose scope this task belongs. May be `null`, indicating a top-level task.

### getOwningTarget

    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.

### setTaskName

    public void setTaskName(java.lang.String name)

  Sets the name to use in logging messages.

  Parameters:
    `name` - The name to use in logging messages. Should not be `null`.

### getTaskName

    public java.lang.String getTaskName()

  Returns the name to use in logging messages.

  Returns:
    the name to use in logging messages.

### setDescription

    public void setDescription(java.lang.String desc)

  Sets a description of the current action. This may be used for logging purposes.

  Parameters:
    `desc` - Description of the current action. May be `null`, indicating that no description is available.

### getDescription

    public java.lang.String getDescription()

  Returns the description of the current action.

  Returns:
    the description of the current action, or `null` if no description is available.

### init

    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 someting goes wrong with the build

### execute

    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

### getLocation

    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`

### setLocation

    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 be `null` - use Location.UNKNOWN_LOCATION if the location isn't known.
  See Also:
    `Location.UNKNOWN_LOCATION`

### getRuntimeConfigurableWrapper

    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.

### setRuntimeConfigurableWrapper

    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 be `null`, in which case the next call to getRuntimeConfigurableWrapper will generate a new wrapper.

### maybeConfigure

    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.

### handleOutput

    protected void handleOutput(java.lang.String line)

  Handles a line of output by logging it with the INFO priority.

  Parameters:
    `line` - The line of output to log. Should not be `null`.

### handleFlush

    protected void handleFlush(java.lang.String line)

  Handles a line of output by logging it with the INFO priority.

  Parameters:
    `line` - The line of output to log. Should not be `null`.
  Since:
    Ant 1.5.2

### handleErrorOutput

    protected void handleErrorOutput(java.lang.String line)

  Handles an error line by logging it with the INFO priority.

  Parameters:
    `line` - The error line to log. Should not be `null`.

### handleErrorFlush

    protected void handleErrorFlush(java.lang.String line)

  Handles an error line by logging it with the INFO priority.

  Parameters:
    `line` - The error line to log. Should not be `null`.
  Since:
    Ant 1.5.2

### log

    public void log(java.lang.String msg)

  Logs a message with the default (INFO) priority.

  Overrides:
    `log` in class `ProjectComponent`
  Parameters:
    `msg` - The message to be logged. Should not be `null`.

### log

    public void log(java.lang.String msg,
                    int msgLevel)

  Logs a mesage with the given priority. This delegates the actual logging to the project.

  Overrides:
    `log` in class `ProjectComponent`
  Parameters:
    `msg` - The message to be logged. Should not be `null`.
    `msgLevel` - The message priority at which this message is to be logged.

### perform

    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.

### isInvalid

    protected final boolean isInvalid()

  Has this task been marked invalid?

  Since:
    Ant 1.5

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.