Browse Source

allow target-group attribute to use a comma-separated list

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@719198 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
08bdfe8f1b
2 changed files with 34 additions and 25 deletions
  1. +10
    -8
      src/main/org/apache/tools/ant/Target.java
  2. +24
    -17
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java

+ 10
- 8
src/main/org/apache/tools/ant/Target.java View File

@@ -125,14 +125,15 @@ public class Target implements TaskContainer {
* depends on. Must not be <code>null</code>.
*/
public void setDepends(String depS) {
for (Iterator iter = parseDepends(depS, getName()).iterator();
for (Iterator iter = parseDepends(depS, getName(), "depends").iterator();
iter.hasNext(); ) {
addDependency((String) iter.next());
}
}

public static List/*<String>*/ parseDepends(String depends,
String targetName) {
String targetName,
String attributeName) {
ArrayList list = new ArrayList();
if (depends.length() > 0) {
StringTokenizer tok =
@@ -142,11 +143,11 @@ public class Target implements TaskContainer {

// Make sure the dependency is not empty string
if ("".equals(token) || ",".equals(token)) {
throw new BuildException("Syntax Error: depends "
+ "attribute of target \""
throw new BuildException("Syntax Error: "
+ attributeName
+ " attribute of target \""
+ targetName
+ "\" has an empty string as "
+ "dependency.");
+ "\" contains an empty string.");
}

list.add(token);
@@ -156,8 +157,9 @@ public class Target implements TaskContainer {
if (tok.hasMoreTokens()) {
token = tok.nextToken();
if (!tok.hasMoreTokens() || !",".equals(token)) {
throw new BuildException("Syntax Error: Depend "
+ "attribute for target \""
throw new BuildException("Syntax Error: "
+ attributeName
+ " attribute for target \""
+ targetName
+ "\" ends with a \",\" "
+ "character");


+ 24
- 17
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -876,9 +876,6 @@ public class ProjectHelper2 extends ProjectHelper {
+ " specify a name attribute");
}
name = prefix + sep + name;
if (targetGroup != null) {
targetGroup = prefix + sep + targetGroup;
}
}

// Check if this target is in the current build file
@@ -904,7 +901,8 @@ public class ProjectHelper2 extends ProjectHelper {
target.setDepends(depends);
} else {
for (Iterator iter =
Target.parseDepends(depends, name).iterator();
Target.parseDepends(depends, name, "depends")
.iterator();
iter.hasNext(); ) {
target.addDependency(prefix + sep + iter.next());
}
@@ -921,20 +919,29 @@ public class ProjectHelper2 extends ProjectHelper {
project.addOrReplaceTarget(newName, newTarget);
}
if (targetGroup != null) {
if (!projectTargets.containsKey(targetGroup)) {
throw new BuildException("can't add target "
+ name + " to target-group "
+ targetGroup
+ " because the target-group"
+ " is unknown.");
}
Target t = (Target) projectTargets.get(targetGroup);
if (!(t instanceof TargetGroup)) {
throw new BuildException("referenced target "
+ targetGroup
+ " is not a target-group");
for (Iterator iter =
Target.parseDepends(targetGroup, name, "target-group")
.iterator();
iter.hasNext(); ) {
String tgName = (String) iter.next();
if (isInIncludeMode()) {
tgName = prefix + sep + tgName;
}
if (!projectTargets.containsKey(tgName)) {
throw new BuildException("can't add target "
+ name + " to target-group "
+ tgName
+ " because the target-group"
+ " is unknown.");
}
Target t = (Target) projectTargets.get(tgName);
if (!(t instanceof TargetGroup)) {
throw new BuildException("referenced target "
+ tgName
+ " is not a target-group");
}
t.addDependency(name);
}
t.addDependency(name);
}
}



Loading…
Cancel
Save