Index: src/tests/antunit/core/extension-point-test.xml
===================================================================
--- src/tests/antunit/core/extension-point-test.xml (revision 937188)
+++ src/tests/antunit/core/extension-point-test.xml (working copy)
@@ -57,7 +57,7 @@
-
+
@@ -83,4 +83,22 @@
+
+
+
+
+
+]]>
+
+
+
+ in target prepare
+
+]]>
+
+
+
+
Index: src/main/org/apache/tools/ant/helper/ProjectHelper2.java
===================================================================
--- src/main/org/apache/tools/ant/helper/ProjectHelper2.java (revision 937188)
+++ src/main/org/apache/tools/ant/helper/ProjectHelper2.java (working copy)
@@ -177,6 +177,28 @@
parse(project, source, new RootHandler(context, mainHandler));
// Execute the top-level target
context.getImplicitTarget().execute();
+
+ // resolve extensionOf attributes
+ for (Iterator i = getExtensionStack().iterator(); i.hasNext(); ) {
+ String[] extensionInfo = (String[]) i.next();
+ String tgName = extensionInfo[0];
+ String name = extensionInfo[1];
+ Hashtable projectTargets = project.getTargets();
+ if (!projectTargets.containsKey(tgName)) {
+ throw new BuildException("can't add target "
+ + name + " to extension-point "
+ + tgName
+ + " because the extension-point"
+ + " is unknown.");
+ }
+ Target t = (Target) projectTargets.get(tgName);
+ if (!(t instanceof ExtensionPoint)) {
+ throw new BuildException("referenced target "
+ + tgName
+ + " is not an extension-point");
+ }
+ t.addDependency(name);
+ }
}
}
@@ -987,6 +1009,9 @@
project.addOrReplaceTarget(newName, newTarget);
}
if (extensionPoint != null) {
+ ProjectHelper helper =
+ (ProjectHelper) context.getProject().
+ getReference(ProjectHelper.PROJECTHELPER_REFERENCE);
for (Iterator iter =
Target.parseDepends(extensionPoint, name, "extensionOf")
.iterator();
@@ -995,20 +1020,12 @@
if (isInIncludeMode()) {
tgName = prefix + sep + tgName;
}
- if (!projectTargets.containsKey(tgName)) {
- throw new BuildException("can't add target "
- + name + " to extension-point "
- + tgName
- + " because the extension-point"
- + " is unknown.");
- }
- Target t = (Target) projectTargets.get(tgName);
- if (!(t instanceof ExtensionPoint)) {
- throw new BuildException("referenced target "
- + tgName
- + " is not an extension-point");
- }
- t.addDependency(name);
+
+ // defer extensionpoint resolution until the full
+ // import stack has been processed
+ helper.getExtensionStack().add(new String[] {
+ tgName, name
+ });
}
}
}
Index: src/main/org/apache/tools/ant/ProjectHelper.java
===================================================================
--- src/main/org/apache/tools/ant/ProjectHelper.java (revision 937188)
+++ src/main/org/apache/tools/ant/ProjectHelper.java (working copy)
@@ -19,6 +19,8 @@
import java.io.File;
import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
import java.util.Vector;
@@ -89,6 +91,7 @@
// that read build files using ProjectHelper ).
private Vector importStack = new Vector();
+ private List extensionStack = new LinkedList();
/**
* Import stack.
@@ -101,6 +104,18 @@
return importStack;
}
+ /**
+ * Extension stack.
+ * Used to keep track of targets that extend extension points.
+ *
+ * @return a list of two element string arrays where the first
+ * element is the name of the extensionpoint and the second the
+ * name of the target
+ */
+ public List getExtensionStack() {
+ return extensionStack;
+ }
+
private final static ThreadLocal targetPrefix = new ThreadLocal() {
protected Object initialValue() {
return (String) null;
Index: contributors.xml
===================================================================
--- contributors.xml (revision 937188)
+++ contributors.xml (working copy)
@@ -178,6 +178,10 @@
Felder
+ Brian
+ Repko
+
+
Bruce
Atherton
Index: CONTRIBUTORS
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream