git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@719198 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -125,14 +125,15 @@ public class Target implements TaskContainer { | |||||
| * depends on. Must not be <code>null</code>. | * depends on. Must not be <code>null</code>. | ||||
| */ | */ | ||||
| public void setDepends(String depS) { | public void setDepends(String depS) { | ||||
| for (Iterator iter = parseDepends(depS, getName()).iterator(); | |||||
| for (Iterator iter = parseDepends(depS, getName(), "depends").iterator(); | |||||
| iter.hasNext(); ) { | iter.hasNext(); ) { | ||||
| addDependency((String) iter.next()); | addDependency((String) iter.next()); | ||||
| } | } | ||||
| } | } | ||||
| public static List/*<String>*/ parseDepends(String depends, | public static List/*<String>*/ parseDepends(String depends, | ||||
| String targetName) { | |||||
| String targetName, | |||||
| String attributeName) { | |||||
| ArrayList list = new ArrayList(); | ArrayList list = new ArrayList(); | ||||
| if (depends.length() > 0) { | if (depends.length() > 0) { | ||||
| StringTokenizer tok = | StringTokenizer tok = | ||||
| @@ -142,11 +143,11 @@ public class Target implements TaskContainer { | |||||
| // Make sure the dependency is not empty string | // Make sure the dependency is not empty string | ||||
| if ("".equals(token) || ",".equals(token)) { | if ("".equals(token) || ",".equals(token)) { | ||||
| throw new BuildException("Syntax Error: depends " | |||||
| + "attribute of target \"" | |||||
| throw new BuildException("Syntax Error: " | |||||
| + attributeName | |||||
| + " attribute of target \"" | |||||
| + targetName | + targetName | ||||
| + "\" has an empty string as " | |||||
| + "dependency."); | |||||
| + "\" contains an empty string."); | |||||
| } | } | ||||
| list.add(token); | list.add(token); | ||||
| @@ -156,8 +157,9 @@ public class Target implements TaskContainer { | |||||
| if (tok.hasMoreTokens()) { | if (tok.hasMoreTokens()) { | ||||
| token = tok.nextToken(); | token = tok.nextToken(); | ||||
| if (!tok.hasMoreTokens() || !",".equals(token)) { | if (!tok.hasMoreTokens() || !",".equals(token)) { | ||||
| throw new BuildException("Syntax Error: Depend " | |||||
| + "attribute for target \"" | |||||
| throw new BuildException("Syntax Error: " | |||||
| + attributeName | |||||
| + " attribute for target \"" | |||||
| + targetName | + targetName | ||||
| + "\" ends with a \",\" " | + "\" ends with a \",\" " | ||||
| + "character"); | + "character"); | ||||
| @@ -876,9 +876,6 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| + " specify a name attribute"); | + " specify a name attribute"); | ||||
| } | } | ||||
| name = prefix + sep + name; | name = prefix + sep + name; | ||||
| if (targetGroup != null) { | |||||
| targetGroup = prefix + sep + targetGroup; | |||||
| } | |||||
| } | } | ||||
| // Check if this target is in the current build file | // Check if this target is in the current build file | ||||
| @@ -904,7 +901,8 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| target.setDepends(depends); | target.setDepends(depends); | ||||
| } else { | } else { | ||||
| for (Iterator iter = | for (Iterator iter = | ||||
| Target.parseDepends(depends, name).iterator(); | |||||
| Target.parseDepends(depends, name, "depends") | |||||
| .iterator(); | |||||
| iter.hasNext(); ) { | iter.hasNext(); ) { | ||||
| target.addDependency(prefix + sep + iter.next()); | target.addDependency(prefix + sep + iter.next()); | ||||
| } | } | ||||
| @@ -921,20 +919,29 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| project.addOrReplaceTarget(newName, newTarget); | project.addOrReplaceTarget(newName, newTarget); | ||||
| } | } | ||||
| if (targetGroup != null) { | 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); | |||||
| } | } | ||||
| } | } | ||||