Google

Target (Apache Ant API)

org.apache.tools.ant
Class Target


java.lang.Object

  |

  +--org.apache.tools.ant.Target

All Implemented Interfaces:
TaskContainer

public class Target
extends java.lang.Object
implements TaskContainer

Class to implement a target object with required parameters.

Author:
James Davidson duncan@x180.com

Constructor Summary
Target()
          Sole constructor.
 
Method Summary
 void addDataType(RuntimeConfigurable r)
          Adds the wrapper for a data type element to this target.
 void addDependency(java.lang.String dependency)
          Adds a dependency to this target.
 void addTask(Task task)
          Adds a task to this target.
 void execute()
          Executes the target if the "if" and "unless" conditions are satisfied.
 java.util.Enumeration getDependencies()
          Returns an enumeration of the dependencies of this target.
 java.lang.String getDescription()
          Returns the description of this target.
 java.lang.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.
 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(java.lang.String depS)
          Sets the list of targets this target is dependent on.
 void setDescription(java.lang.String description)
          Sets the description of this target.
 void setIf(java.lang.String property)
          Sets the "if" condition to test on execution.
 void setName(java.lang.String name)
          Sets the name of this target.
 void setProject(Project project)
          Sets the project this target belongs to.
 void setUnless(java.lang.String property)
          Sets the "unless" condition to test on execution.
 java.lang.String toString()
          Returns the name of this target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Target


public Target()
Sole constructor.

Method Detail

setProject


public void setProject(Project project)
Sets the project this target belongs to.

Parameters:
project - The project this target belongs to. Must not be null.

getProject


public Project getProject()
Returns the project this target belongs to.

Returns:
The project this target belongs to, or null if the project has not been set yet.

setDepends


public 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.

setName


public void setName(java.lang.String name)
Sets the name of this target.

Parameters:
name - The name of this target. Should not be null.

getName


public java.lang.String getName()
Returns the name of this target.

Returns:
the name of this target, or null if the name has not been set yet.

addTask


public void addTask(Task task)
Adds a task to this target.

Specified by:
addTask in interface TaskContainer
Parameters:
task - The task to be added. Must not be null.

addDataType


public 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.

getTasks


public Task[] getTasks()
Returns the current set of tasks to be executed by this target.

Returns:
an array of the tasks currently within this target

addDependency


public 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.

getDependencies


public java.util.Enumeration getDependencies()
Returns an enumeration of the dependencies of this target.

Returns:
an enumeration of the dependencies of this target

setIf


public 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 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.

Parameters:
property - The property condition to test on execution. May be null, in which case no "if" test is performed.

setUnless


public 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 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.

Parameters:
property - The property condition to test on execution. May be null, in which case no "unless" test is performed.

setDescription


public 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.

getDescription


public java.lang.String getDescription()
Returns the description of this target.

Returns:
the description of this target, or null if no description is available.

toString


public java.lang.String toString()
Returns the name of this target.

Overrides:
toString in class java.lang.Object
Returns:
the name of this target, or null if the name has not been set yet.

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.

Throws:
BuildException - if any of the tasks fail or if a data type configuration fails.
See Also:
performTasks(), setIf(String), setUnless(String)

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.

See Also:
execute()


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