Author: hibou
Date: Wed Jun 13 20:22:26 2012
New Revision: 1350000
URL: http://svn.apache.org/viewvc?rev=1350000&view=rev
Log:
#53405 : ExtensionPoint doesn't work with nested import/include
Thanks to Jean-Louis Boudart
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/ExtensionPoint.java
ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
ant/core/trunk/src/tests/antunit/core/extension-point-test.xml
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1350000&r1=1349999&r2=1350000&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Wed Jun 13 20:22:26 2012
@@ -157,6 +157,7 @@ Jay van der Meer
JC Mann
J D Glanville
Jean-Francois Brousseau
+Jean-Louis Boudart
Jeff Gettle
Jeff Martin
Jeff Tulley
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1350000&r1=1349999&r2=1350000&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Jun 13 20:22:26 2012
@@ -30,6 +30,9 @@ Fixed bugs:
* <javac> by default fails when run on JDK 8.
Bugzilla Report 53347.
+ * ExtensionPoint doesn't work with nested import/include
+ Bugzilla Report 53405.
+
Other changes:
--------------
Modified: ant/core/trunk/src/main/org/apache/tools/ant/ExtensionPoint.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ExtensionPoint.java?rev=1350000&r1=1349999&r2=1350000&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ExtensionPoint.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ExtensionPoint.java Wed Jun 13
20:22:26 2012
@@ -25,8 +25,19 @@ package org.apache.tools.ant;
*/
public class ExtensionPoint extends Target {
- // no "clone" constructor since I'm not really sure where it is
- // used
+ public ExtensionPoint() {
+
+ }
+
+ /**
+ * Cloning constructor.
+ * @param other the Target to clone.
+ */
+ public ExtensionPoint(Target other) {
+ //Should we have a clone constructor taking an ExtensionPoint as
parameter?
+ super(other);
+ }
+
private static final String NO_CHILDREN_ALLOWED
= "you must not nest child elements into an extension-point";
@@ -45,4 +56,4 @@ public class ExtensionPoint extends Targ
throw new BuildException(NO_CHILDREN_ALLOWED);
}
-}
\ No newline at end of file
+}
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=1350000&r1=1349999&r2=1350000&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
Jun 13 20:22:26 2012
@@ -1019,7 +1019,11 @@ public class ProjectHelper2 extends Proj
// In an imported file (and not completely
// ignoring the project tag or having a preconfigured prefix)
String newName = prefix + sep + name;
- Target newTarget = usedTarget ? new Target(target) : target;
+ Target newTarget = target;
+ if (usedTarget) {
+ newTarget = "target".equals(tag)
+ ? new Target(target) : new ExtensionPoint(target);
+ }
newTarget.setName(newName);
context.getCurrentTargets().put(newName, newTarget);
project.addOrReplaceTarget(newName, newTarget);
Modified: ant/core/trunk/src/tests/antunit/core/extension-point-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/extension-point-test.xml?rev=1350000&r1=1349999&r2=1350000&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/core/extension-point-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/core/extension-point-test.xml Wed Jun 13
20:22:26 2012
@@ -88,6 +88,80 @@
<au:assertLogContains text="in target prepare"/>
</target>
+ <target name="testExtensionPointInIncludedBuildfileWithNestedInclude">
+ <mkdir dir="output"/>
+ <echo file="output/abstract-compile.xml"><![CDATA[
+<project name="abstract-compile">
+ <extension-point name="compile"/>
+</project>]]></echo>
+ <echo file="output/compile-java.xml"><![CDATA[
+<project name="compile-java">
+ <include file="abstract-compile.xml" as="abstract-compile"/>
+ <target name="compile-java" extensionOf="abstract-compile.compile">
+ <echo>in compile java</echo>
+ </target>
+</project>]]></echo>
+ <echo file="output/build.xml"><![CDATA[
+<project name="master">
+ <include file="compile-java.xml" as="compile"/>
+</project>]]></echo>
+ <!-- here prefix should be concatened from each include first
+ "compile" then "abstract-compile"-->
+ <ant dir="output" target="compile.abstract-compile.compile"/>
+ <au:assertLogContains text="in compile java"/>
+
+ </target>
+
+ <target name="testExtensionPointInIncludedBuildfileWithNestedImport">
+ <mkdir dir="output"/>
+ <echo file="output/abstract-compile.xml"><![CDATA[
+<project name="abstract-compile">
+ <extension-point name="compile"/>
+</project>]]></echo>
+ <echo file="output/compile-java.xml"><![CDATA[
+<project name="compile-java">
+ <import file="abstract-compile.xml"/>
+ <target name="compile-java" extensionOf="compile">
+ <echo>in compile java</echo>
+ </target>
+</project>]]></echo>
+ <echo file="output/build.xml"><![CDATA[
+<project name="master">
+ <include file="compile-java.xml" as="compile"/>
+</project>]]></echo>
+ <!-- here the prefix should be "compile" as the import containing
+ the extension point is done inside an include using "compile"
+ as prefix -->
+ <ant dir="output" target="compile.compile"/>
+ <au:assertLogContains text="in compile java"/>
+
+ </target>
+
+ <target name="testExtensionPointInImportedBuildfileWithNestedImport">
+ <mkdir dir="output"/>
+ <echo file="output/abstract-compile.xml"><![CDATA[
+<project name="abstract-compile">
+ <extension-point name="compile"/>
+</project>]]></echo>
+ <echo file="output/compile-java.xml"><![CDATA[
+<project name="compile-java">
+ <import file="abstract-compile.xml"/>
+ <target name="compile-java" extensionOf="compile">
+ <echo>in compile java</echo>
+ </target>
+</project>]]></echo>
+ <echo file="output/build.xml"><![CDATA[
+<project name="master">
+ <import file="compile-java.xml"/>
+</project>]]></echo>
+ <!-- here extension point should not be prefixed at all -->
+ <ant dir="output" target="compile"/>
+ <au:assertLogContains text="in compile java"/>
+
+ </target>
+
+
+
<target name="testMissingExtensionPointCausesError">
<mkdir dir="${output}"/>
<echo file="${output}/build.xml"><![CDATA[