org.apache.tools.ant
Class Target
java.lang.Object
org.apache.tools.ant.Target
- TaskContainer
public class Target
extends java.lang.Object
Class to implement a target object with required parameters.
void | addDataType(RuntimeConfigurable r) - Adds the wrapper for a data type element to this target.
|
void | addDependency(String dependency) - Adds a dependency to this target.
|
void | addTask(Task task) - Adds a task to this target.
|
boolean | dependsOn(String other) - Does this target depend on the named target?
|
void | execute() - Executes the target if the "if" and "unless" conditions are
satisfied.
|
Enumeration | getDependencies() - Returns an enumeration of the dependencies of this target.
|
String | getDescription() - Returns the description of this target.
|
String | getIf() - Returns the "if" property condition of this target.
|
Location | getLocation() - Get the location of this target's definition.
|
String | getName() - Returns the name of this target.
|
Project | getProject() - Returns the project this target belongs to.
|
Task[] | getTasks() - Returns the current set of tasks to be executed by this target.
|
String | getUnless() - Returns the "unless" property condition of this target.
|
void | performTasks() - Performs the tasks within this target (if the conditions are met),
firing target started/target finished messages around a call to
execute.
|
void | setDepends(String depS) - Sets the list of targets this target is dependent on.
|
void | setDescription(String description) - Sets the description of this target.
|
void | setIf(String property) - Sets the "if" condition to test on execution.
|
void | setLocation(Location location) - Sets the location of this target's definition.
|
void | setName(String name) - Sets the name of this target.
|
void | setProject(Project project) - Sets the project this target belongs to.
|
void | setUnless(String property) - Sets the "unless" condition to test on execution.
|
String | toString() - Returns the name of this target.
|
Target
public Target()
Sole constructor.
addDataType
public void addDataType(RuntimeConfigurable r)
Adds the wrapper for a data type element to this target.
r
- The wrapper for the data type element to be added.
Must not be null
.
addDependency
public void addDependency(String dependency)
Adds a dependency to this target.
dependency
- The name of a target this target is dependent on.
Must not be null
.
addTask
public void addTask(Task task)
Adds a task to this target.
- addTask in interface TaskContainer
task
- The task to be added. Must not be null
.
dependsOn
public boolean dependsOn(String other)
Does this target depend on the named target?
other
- the other named target.
- true if the target does depend on the named target
execute
public void execute()
throws BuildException
Executes the target if the "if" and "unless" conditions are
satisfied. Dependency checking should be done before calling this
method, as it does no checking of its own. If either the "if"
or "unless" test prevents this target from being executed, a verbose
message is logged giving the reason. It is recommended that clients
of this class call performTasks rather than this method so that
appropriate build events are fired.
BuildException
- if any of the tasks fail or if a data type
configuration fails.
getDependencies
public Enumeration getDependencies()
Returns an enumeration of the dependencies of this target.
- an enumeration of the dependencies of this target
getDescription
public String getDescription()
Returns the description of this target.
- the description of this target, or
null
if no
description is available.
getIf
public String getIf()
Returns the "if" property condition of this target.
- the "if" property condition or
null
if no
"if" condition had been defined.
getLocation
public Location getLocation()
Get the location of this target's definition.
getName
public String getName()
Returns the name of this target.
- the name of this target, or
null
if the
name has not been set yet.
getProject
public Project getProject()
Returns the project this target belongs to.
- The project this target belongs to, or
null
if
the project has not been set yet.
getTasks
public Task[] getTasks()
Returns the current set of tasks to be executed by this target.
- an array of the tasks currently within this target
getUnless
public String getUnless()
Returns the "unless" property condition of this target.
- the "unless" property condition or
null
if no "unless" condition had been defined.
performTasks
public final void performTasks()
Performs the tasks within this target (if the conditions are met),
firing target started/target finished messages around a call to
execute.
setDepends
public void setDepends(String depS)
Sets the list of targets this target is dependent on.
The targets themselves are not resolved at this time.
depS
- A comma-separated list of targets this target
depends on. Must not be null
.
setDescription
public void setDescription(String description)
Sets the description of this target.
description
- The description for this target.
May be null
, indicating that no
description is available.
setIf
public void setIf(String property)
Sets the "if" condition to test on execution. This is the
name of a property to test for existence - if the property
is not set, the task will not execute. The property goes
through property substitution once before testing, so if
property foo
has value bar
, setting
the "if" condition to ${foo}_x
will mean that the
task will only execute if property bar_x
is set.
property
- The property condition to test on execution.
May be null
, in which case
no "if" test is performed.
setLocation
public void setLocation(Location location)
Sets the location of this target's definition.
setName
public void setName(String name)
Sets the name of this target.
name
- The name of this target. Should not be null
.
setProject
public void setProject(Project project)
Sets the project this target belongs to.
project
- The project this target belongs to.
Must not be null
.
setUnless
public void setUnless(String property)
Sets the "unless" condition to test on execution. This is the
name of a property to test for existence - if the property
is set, the task will not execute. The property goes
through property substitution once before testing, so if
property foo
has value bar
, setting
the "unless" condition to ${foo}_x
will mean that the
task will only execute if property bar_x
isn't set.
property
- The property condition to test on execution.
May be null
, in which case
no "unless" test is performed.
toString
public String toString()
Returns the name of this target.
- the name of this target, or
null
if the
name has not been set yet.
Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.