You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/20 09:45:52 UTC

svn commit: r719198 - in /ant/core/trunk/src/main/org/apache/tools/ant: Target.java helper/ProjectHelper2.java

Author: bodewig
Date: Thu Nov 20 00:45:52 2008
New Revision: 719198

URL: http://svn.apache.org/viewvc?rev=719198&view=rev
Log:
allow target-group attribute to use a comma-separated list

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/Target.java
    ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Target.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Target.java?rev=719198&r1=719197&r2=719198&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Target.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Target.java Thu Nov 20 00:45:52 2008
@@ -125,14 +125,15 @@
      *             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 @@
 
                 // 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 @@
                 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");

Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java?rev=719198&r1=719197&r2=719198&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Thu Nov 20 00:45:52 2008
@@ -876,9 +876,6 @@
                                              + " 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 @@
                     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 @@
                 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);
             }
         }