Package org.apache.tools.ant
Class Target
- java.lang.Object
- 
- org.apache.tools.ant.Target
 
- 
- All Implemented Interfaces:
- TaskContainer
 - Direct Known Subclasses:
- ExtensionPoint
 
 public class Target extends java.lang.Object implements TaskContainer Class to implement a target object with required parameters.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. 
- 
- 
Method SummaryModifier and Type Method Description voidaddDataType(RuntimeConfigurable r)Adds the wrapper for a data type element to this target.voidaddDependency(java.lang.String dependency)Adds a dependency to this target.voidaddTask(Task task)Adds a task to this target.booleandependsOn(java.lang.String other)Does this target depend on the named target?voidexecute()Executes the target if the "if" and "unless" conditions are satisfied.java.util.Enumeration<java.lang.String>getDependencies()Returns an enumeration of the dependencies of this target.java.lang.StringgetDescription()Returns the description of this target.java.lang.StringgetIf()Returns the "if" property condition of this target.LocationgetLocation()Get the location of this target's definition.java.lang.StringgetName()Returns the name of this target.ProjectgetProject()Returns the project this target belongs to.Task[]getTasks()Returns the current set of tasks to be executed by this target.java.lang.StringgetUnless()Returns the "unless" property condition of this target.static java.util.List<java.lang.String>parseDepends(java.lang.String depends, java.lang.String targetName, java.lang.String attributeName)voidperformTasks()Performs the tasks within this target (if the conditions are met), firing target started/target finished messages around a call to execute.voidsetDepends(java.lang.String depS)Sets the list of targets this target is dependent on.voidsetDescription(java.lang.String description)Sets the description of this target.voidsetIf(java.lang.String property)Sets the "if" condition to test on execution.voidsetIf(Condition condition)Same assetIf(String)but requires aConditioninstancevoidsetLocation(Location location)Sets the location of this target's definition.voidsetName(java.lang.String name)Sets the name of this target.voidsetProject(Project project)Sets the project this target belongs to.voidsetUnless(java.lang.String property)Sets the "unless" condition to test on execution.voidsetUnless(Condition condition)Same assetUnless(String)but requires aConditioninstancejava.lang.StringtoString()Returns the name of this target.
 
- 
- 
- 
Constructor Detail- 
Targetpublic Target() Default constructor.
 - 
Targetpublic Target(Target other) Cloning constructor.- Parameters:
- other- the Target to clone.
 
 
- 
 - 
Method Detail- 
setProjectpublic void setProject(Project project) Sets the project this target belongs to.- Parameters:
- project- The project this target belongs to. Must not be- null.
 
 - 
getProjectpublic Project getProject() Returns the project this target belongs to.- Returns:
- The project this target belongs to, or nullif the project has not been set yet.
 
 - 
setLocationpublic void setLocation(Location location) Sets the location of this target's definition.- Parameters:
- location-- Location
- Since:
- 1.6.2
 
 - 
getLocationpublic Location getLocation() Get the location of this target's definition.- Returns:
- Location
- Since:
- 1.6.2
 
 - 
setDependspublic void setDepends(java.lang.String depS) Sets the list of targets this target is dependent on. The targets themselves are not resolved at this time.- Parameters:
- depS- A comma-separated list of targets this target depends on. Must not be- null.
 
 - 
parseDependspublic static java.util.List<java.lang.String> parseDepends(java.lang.String depends, java.lang.String targetName, java.lang.String attributeName)
 - 
setNamepublic void setName(java.lang.String name) Sets the name of this target.- Parameters:
- name- The name of this target. Should not be- null.
 
 - 
getNamepublic java.lang.String getName() Returns the name of this target.- Returns:
- the name of this target, or nullif the name has not been set yet.
 
 - 
addTaskpublic void addTask(Task task) Adds a task to this target.- Specified by:
- addTaskin interface- TaskContainer
- Parameters:
- task- The task to be added. Must not be- null.
 
 - 
addDataTypepublic void addDataType(RuntimeConfigurable r) Adds the wrapper for a data type element to this target.- Parameters:
- r- The wrapper for the data type element to be added. Must not be- null.
 
 - 
getTaskspublic Task[] getTasks() Returns the current set of tasks to be executed by this target.- Returns:
- an array of the tasks currently within this target
 
 - 
addDependencypublic void addDependency(java.lang.String dependency) Adds a dependency to this target.- Parameters:
- dependency- The name of a target this target is dependent on. Must not be- null.
 
 - 
getDependenciespublic java.util.Enumeration<java.lang.String> getDependencies() Returns an enumeration of the dependencies of this target.- Returns:
- an enumeration of the dependencies of this target (enumeration of String)
 
 - 
dependsOnpublic boolean dependsOn(java.lang.String other) Does this target depend on the named target?- Parameters:
- other- the other named target.
- Returns:
- true if the target does depend on the named target
- Since:
- Ant 1.6
 
 - 
setIfpublic void setIf(java.lang.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 propertyfoohas valuebar, setting the "if" condition to${foo}_xwill mean that the task will only execute if propertybar_xis set.- Parameters:
- property- The property condition to test on execution. May be- null, in which case no "if" test is performed.
 
 - 
getIfpublic java.lang.String getIf() Returns the "if" property condition of this target.- Returns:
- the "if" property condition or nullif no "if" condition had been defined.
- Since:
- 1.6.2
 
 - 
setIfpublic void setIf(Condition condition) Same assetIf(String)but requires aConditioninstance- Parameters:
- condition- Condition
- Since:
- 1.9
 
 - 
setUnlesspublic void setUnless(java.lang.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 propertyfoohas valuebar, setting the "unless" condition to${foo}_xwill mean that the task will only execute if propertybar_xisn't set.- Parameters:
- property- The property condition to test on execution. May be- null, in which case no "unless" test is performed.
 
 - 
getUnlesspublic java.lang.String getUnless() Returns the "unless" property condition of this target.- Returns:
- the "unless" property condition or nullif no "unless" condition had been defined.
- Since:
- 1.6.2
 
 - 
setUnlesspublic void setUnless(Condition condition) Same assetUnless(String)but requires aConditioninstance- Parameters:
- condition- Condition
- Since:
- 1.9
 
 - 
setDescriptionpublic void setDescription(java.lang.String description) Sets the description of this target.- Parameters:
- description- The description for this target. May be- null, indicating that no description is available.
 
 - 
getDescriptionpublic java.lang.String getDescription() Returns the description of this target.- Returns:
- the description of this target, or nullif no description is available.
 
 - 
toStringpublic java.lang.String toString() Returns the name of this target.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the name of this target, or nullif the name has not been set yet.
 
 - 
executepublic void execute() throws BuildExceptionExecutes 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.- Throws:
- BuildException- if any of the tasks fail or if a data type configuration fails.
- See Also:
- performTasks(),- setIf(String),- setUnless(String)
 
 - 
performTaskspublic 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.- See Also:
- execute()
 
 
- 
 
-