ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1373321 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/ProjectHelper.java src/main/org/apache/tools/ant/helper/ProjectHelper2.java
Date Wed, 15 Aug 2012 10:37:23 GMT
Author: hibou
Date: Wed Aug 15 10:37:23 2012
New Revision: 1373321

URL: http://svn.apache.org/viewvc?rev=1373321&view=rev
Log:
BR 53549
Make the ProjectHelper class expose the method which properly bind targets and extension points.
Thanks to Jean-Louis Boudart

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

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1373321&r1=1373320&r2=1373321&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Aug 15 10:37:23 2012
@@ -83,6 +83,11 @@ Other changes:
    it is more portable.  For backwards compatibility reasons "warn"
    will still create "gnu" extensions rather than "posix" extensions.
 
+ * The ProjectHelper class now exposes a method to be used by third party
+   implementations to properly resolve the binding between target extensions
+   and extension points.
+   Bugzilla Report 53549.
+
 Changes from Ant 1.8.3 TO Ant 1.8.4
 ===================================
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java?rev=1373321&r1=1373320&r2=1373321&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ProjectHelper.java Wed Aug 15 10:37:23 2012
@@ -606,4 +606,51 @@ public class ProjectHelper {
     public String getDefaultBuildFile() {
         return Main.DEFAULT_BUILD_FILENAME;
     }
+
+    /**
+     * Check extensionStack and inject all targets having extensionOf attributes
+     * into extensionPoint.
+     * <p>
+     * This method allow you to defer injection and have a powerful control of
+     * extensionPoint wiring.
+     * </p>
+     * <p>
+     * This should be invoked by each concrete implementation of ProjectHelper
+     * when the root "buildfile" and all imported/included buildfile are loaded.
+     * </p>
+     * 
+     * @param project The project containing the target. Must not be
+     *            <code>null</code>.
+     * @exception BuildException if OnMissingExtensionPoint.FAIL and
+     *                extensionPoint does not exist
+     * @see OnMissingExtensionPoint
+     * @since 1.9
+     */
+    public void resolveExtensionOfAttributes(Project project)
+            throws BuildException {
+        for (String[] extensionInfo : getExtensionStack()) {
+            String tgName = extensionInfo[0];
+            String name = extensionInfo[1];
+            OnMissingExtensionPoint missingBehaviour = OnMissingExtensionPoint.valueOf(extensionInfo[2]);
+            Hashtable projectTargets = project.getTargets();
+            if (!projectTargets.containsKey(tgName)) {
+                String message = "can't add target " + name
+                        + " to extension-point " + tgName
+                        + " because the extension-point is unknown.";
+                if (missingBehaviour == OnMissingExtensionPoint.FAIL) {
+                    throw new BuildException(message);
+                } else if (missingBehaviour == OnMissingExtensionPoint.WARN) {
+                    Target target = (Target) projectTargets.get(name);
+                    project.log(target, "Warning: " + message, Project.MSG_WARN);
+                }
+            } else {
+                Target t = (Target) projectTargets.get(tgName);
+                if (!(t instanceof ExtensionPoint)) {
+                    throw new BuildException("referenced target " + tgName
+                            + " is not an extension-point");
+                }
+                t.addDependency(name);
+            }
+        }
+    }
 }

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=1373321&r1=1373320&r2=1373321&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 Wed Aug 15 10:37:23
2012
@@ -180,34 +180,7 @@ public class ProjectHelper2 extends Proj
             context.getImplicitTarget().execute();
 
             // resolve extensionOf attributes
-            for (String[] extensionInfo : getExtensionStack()) {
-                String tgName = extensionInfo[0];
-                String name = extensionInfo[1];
-                OnMissingExtensionPoint missingBehaviour = OnMissingExtensionPoint
-                        .valueOf(extensionInfo[2]);
-                Hashtable projectTargets = project.getTargets();
-                if (!projectTargets.containsKey(tgName)) {
-                    String message = "can't add target " + name
-                        + " to extension-point " + tgName
-                        + " because the extension-point is unknown.";
-                    if (missingBehaviour == OnMissingExtensionPoint.FAIL) {
-                        throw new BuildException(message);
-                    } else if (missingBehaviour == OnMissingExtensionPoint.WARN) {
-                        Target target = (Target) projectTargets.get(name);
-                        context.getProject().log(target,
-                                                 "Warning: " + message,
-                                                 Project.MSG_WARN);
-                    }
-                } else {
-                    Target t = (Target) projectTargets.get(tgName);
-                    if (!(t instanceof ExtensionPoint)) {
-                        throw new BuildException("referenced target "
-                                                 + tgName
-                                                 + " is not an extension-point");
-                    }
-                    t.addDependency(name);
-                }
-            }
+            resolveExtensionOfAttributes(project);
         }
     }
 



Mime
View raw message