Browse Source

#53405 : ExtensionPoint doesn't work with nested import/include

Thanks to Jean-Louis Boudart


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1350000 13f79535-47bb-0310-9956-ffa450edef68
master
Nicolas Lalevee 13 years ago
parent
commit
91daac5ad7
5 changed files with 97 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +14
    -3
      src/main/org/apache/tools/ant/ExtensionPoint.java
  4. +5
    -1
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  5. +74
    -0
      src/tests/antunit/core/extension-point-test.xml

+ 1
- 0
CONTRIBUTORS View File

@@ -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


+ 3
- 0
WHATSNEW View File

@@ -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:
--------------



+ 14
- 3
src/main/org/apache/tools/ant/ExtensionPoint.java View File

@@ -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 Target {
throw new BuildException(NO_CHILDREN_ALLOWED);
}
}
}

+ 5
- 1
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -1019,7 +1019,11 @@ public class ProjectHelper2 extends ProjectHelper {
// 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);


+ 74
- 0
src/tests/antunit/core/extension-point-test.xml View File

@@ -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[


Loading…
Cancel
Save