public class Target extends Object implements TaskContainer
If you are creating Targets programmatically, make sure you set the Location to a useful value. In particular all targets should have different location values.
Constructor and Description |
---|
Target()
Default constructor.
|
Target(Target other)
Cloning constructor.
|
Modifier and Type | Method and Description |
---|---|
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<String> |
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.
|
static List<String> |
parseDepends(String depends,
String targetName,
String attributeName) |
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(Condition condition)
Same as
setIf(String) but requires a Condition instance |
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(Condition condition)
Same as
setUnless(String) but requires a Condition instance |
void |
setUnless(String property)
Sets the "unless" condition to test on execution.
|
String |
toString()
Returns the name of this target.
|
public Target()
public Target(Target other)
other
- the Target to clone.public void addDataType(RuntimeConfigurable r)
r
- The wrapper for the data type element to be added.
Must not be null
.public void addDependency(String dependency)
dependency
- The name of a target this target is dependent on.
Must not be null
.public void addTask(Task task)
addTask
in interface TaskContainer
task
- The task to be added. Must not be null
.public boolean dependsOn(String other)
other
- the other named target.public void execute() throws BuildException
BuildException
- if any of the tasks fail or if a data type
configuration fails.performTasks()
,
setIf(String)
,
setUnless(String)
public Enumeration<String> getDependencies()
public String getDescription()
null
if no
description is available.public String getIf()
null
if no
"if" condition had been defined.public Location getLocation()
Location
public String getName()
null
if the
name has not been set yet.public Project getProject()
null
if
the project has not been set yet.public Task[] getTasks()
public String getUnless()
null
if no "unless" condition had been defined.public static List<String> parseDepends(String depends, String targetName, String attributeName)
public final void performTasks()
execute()
public void setDepends(String depS)
depS
- A comma-separated list of targets this target
depends on. Must not be null
.public void setDescription(String description)
description
- The description for this target.
May be null
, indicating that no
description is available.public void setIf(Condition condition)
setIf(String)
but requires a Condition
instancepublic void setIf(String 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.public void setLocation(Location location)
location
- Location
public void setName(String name)
name
- The name of this target. Should not be null
.public void setProject(Project project)
project
- The project this target belongs to.
Must not be null
.public void setUnless(Condition condition)
setUnless(String)
but requires a Condition
instancepublic void setUnless(String 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.