Methods Summary |
---|
public void | addDataType(RuntimeConfigurable r)Adds the wrapper for a data type element to this target.
children.add(r);
|
public void | addDependency(java.lang.String dependency)Adds a dependency to this target.
if (dependencies == null) {
dependencies = new ArrayList(2);
}
dependencies.add(dependency);
|
public void | addTask(Task task)Adds a task to this target.
children.add(task);
|
public boolean | dependsOn(java.lang.String other)Does this target depend on the named target?
Project p = getProject();
Hashtable t = (p == null) ? null : p.getTargets();
return (p != null
&& p.topoSort(getName(), t, false).contains(t.get(other)));
|
public void | execute()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.
if (testIfCondition() && testUnlessCondition()) {
for (int taskPosition = 0;
taskPosition < children.size();
++taskPosition) {
Object o = children.get(taskPosition);
if (o instanceof Task) {
Task task = (Task) o;
task.perform();
} else {
RuntimeConfigurable r = (RuntimeConfigurable) o;
r.maybeConfigure(project);
}
}
} else if (!testIfCondition()) {
project.log(this, "Skipped because property '"
+ project.replaceProperties(ifCondition)
+ "' not set.", Project.MSG_VERBOSE);
} else {
project.log(this, "Skipped because property '"
+ project.replaceProperties(unlessCondition)
+ "' set.", Project.MSG_VERBOSE);
}
|
public java.util.Enumeration | getDependencies()Returns an enumeration of the dependencies of this target.
return (dependencies != null ? Collections.enumeration(dependencies)
: new CollectionUtils.EmptyEnumeration());
|
public java.lang.String | getDescription()Returns the description of this target.
return description;
|
public java.lang.String | getIf()Returns the "if" property condition of this target.
return ("".equals(ifCondition) ? null : ifCondition);
|
public Location | getLocation()Get the location of this target's definition.
return location;
|
public java.lang.String | getName()Returns the name of this target.
return name;
|
public Project | getProject()Returns the project this target belongs to.
return project;
|
public Task[] | getTasks()Returns the current set of tasks to be executed by this target.
List tasks = new ArrayList(children.size());
Iterator it = children.iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof Task) {
tasks.add(o);
}
}
return (Task[]) tasks.toArray(new Task[tasks.size()]);
|
public java.lang.String | getUnless()Returns the "unless" property condition of this target.
return ("".equals(unlessCondition) ? null : unlessCondition);
|
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.
RuntimeException thrown = null;
project.fireTargetStarted(this);
try {
execute();
} catch (RuntimeException exc) {
thrown = exc;
throw exc;
} finally {
project.fireTargetFinished(this, thrown);
}
|
void | replaceChild(Task el, RuntimeConfigurable o)Replaces all occurrences of the given task in the list
of children with the replacement data type wrapper.
int index;
while ((index = children.indexOf(el)) >= 0) {
children.set(index, o);
}
|
void | replaceChild(Task el, Task o)Replaces all occurrences of the given task in the list
of children with the replacement task.
int index;
while ((index = children.indexOf(el)) >= 0) {
children.set(index, o);
}
|
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.
if (depS.length() > 0) {
StringTokenizer tok =
new StringTokenizer(depS, ",", true);
while (tok.hasMoreTokens()) {
String token = tok.nextToken().trim();
// Make sure the dependency is not empty string
if ("".equals(token) || ",".equals(token)) {
throw new BuildException("Syntax Error: depends "
+ "attribute of target \"" + getName()
+ "\" has an empty string as dependency.");
}
addDependency(token);
// Make sure that depends attribute does not
// end in a ,
if (tok.hasMoreTokens()) {
token = tok.nextToken();
if (!tok.hasMoreTokens() || !",".equals(token)) {
throw new BuildException("Syntax Error: Depend "
+ "attribute for target \"" + getName()
+ "\" ends with a , character");
}
}
}
}
|
public void | setDescription(java.lang.String description)Sets the description of this target.
this.description = description;
|
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.
ifCondition = (property == null) ? "" : property;
|
public void | setLocation(Location location)Sets the location of this target's definition.
this.location = location;
|
public void | setName(java.lang.String name)Sets the name of this target.
this.name = name;
|
public void | setProject(Project project)Sets the project this target belongs to.
this.project = project;
|
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.
unlessCondition = (property == null) ? "" : property;
|
private boolean | testIfCondition()Tests whether or not the "if" condition is satisfied.
if ("".equals(ifCondition)) {
return true;
}
String test = project.replaceProperties(ifCondition);
return project.getProperty(test) != null;
|
private boolean | testUnlessCondition()Tests whether or not the "unless" condition is satisfied.
if ("".equals(unlessCondition)) {
return true;
}
String test = project.replaceProperties(unlessCondition);
return project.getProperty(test) == null;
|
public java.lang.String | toString()Returns the name of this target.
return name;
|