View | Details | Raw Unified | Return to bug 53405
Collapse All | Expand All

(-)src/tests/antunit/core/extension-point-test.xml (+74 lines)
Lines 88-93 Link Here
88
    <au:assertLogContains text="in target prepare"/>
88
    <au:assertLogContains text="in target prepare"/>
89
  </target>
89
  </target>
90
90
91
  <target name="testExtensionPointInIncludedBuildfileWithNestedInclude">
92
    <mkdir dir="output"/>
93
    <echo file="output/abstract-compile.xml"><![CDATA[
94
<project name="abstract-compile">
95
  <extension-point name="compile"/>
96
</project>]]></echo>
97
    <echo file="output/compile-java.xml"><![CDATA[
98
<project name="compile-java">
99
  <include file="abstract-compile.xml" as="abstract-compile"/>
100
  <target name="compile-java" extensionOf="abstract-compile.compile">
101
    <echo>in compile java</echo>
102
  </target>
103
</project>]]></echo>
104
    <echo file="output/build.xml"><![CDATA[
105
<project name="master">
106
  <include file="compile-java.xml" as="compile"/>
107
</project>]]></echo>
108
    <!-- here prefix should be concatened from each include first 
109
         "compile" then "abstract-compile"-->
110
    <ant dir="output" target="compile.abstract-compile.compile"/>
111
    <au:assertLogContains text="in compile java"/>
112
113
  </target>
114
115
  <target name="testExtensionPointInIncludedBuildfileWithNestedImport">
116
    <mkdir dir="output"/>
117
    <echo file="output/abstract-compile.xml"><![CDATA[
118
<project name="abstract-compile">
119
  <extension-point name="compile"/>
120
</project>]]></echo>
121
    <echo file="output/compile-java.xml"><![CDATA[
122
<project name="compile-java">
123
  <import file="abstract-compile.xml"/>
124
  <target name="compile-java" extensionOf="compile">
125
    <echo>in compile java</echo>
126
  </target>
127
</project>]]></echo>
128
    <echo file="output/build.xml"><![CDATA[
129
<project name="master">
130
  <include file="compile-java.xml" as="compile"/>
131
</project>]]></echo>
132
    <!-- here the prefix should be "compile" as the import containing
133
         the extension point is done inside an include using "compile"
134
         as prefix -->
135
    <ant dir="output" target="compile.compile"/>
136
    <au:assertLogContains text="in compile java"/>
137
138
  </target>
139
140
  <target name="testExtensionPointInImportedBuildfileWithNestedImport">
141
    <mkdir dir="output"/>
142
    <echo file="output/abstract-compile.xml"><![CDATA[
143
<project name="abstract-compile">
144
  <extension-point name="compile"/>
145
</project>]]></echo>
146
    <echo file="output/compile-java.xml"><![CDATA[
147
<project name="compile-java">
148
  <import file="abstract-compile.xml"/>
149
  <target name="compile-java" extensionOf="compile">
150
    <echo>in compile java</echo>
151
  </target>
152
</project>]]></echo>
153
    <echo file="output/build.xml"><![CDATA[
154
<project name="master">
155
  <import file="compile-java.xml"/>
156
</project>]]></echo>
157
    <!-- here extension point should not be prefixed at all -->
158
    <ant dir="output" target="compile"/>
159
    <au:assertLogContains text="in compile java"/>
160
161
  </target>
162
163
164
91
  <target name="testMissingExtensionPointCausesError">
165
  <target name="testMissingExtensionPointCausesError">
92
    <mkdir dir="${output}"/>
166
    <mkdir dir="${output}"/>
93
    <echo file="${output}/build.xml"><![CDATA[
167
    <echo file="${output}/build.xml"><![CDATA[
(-)src/main/org/apache/tools/ant/helper/ProjectHelper2.java (-1 / +4 lines)
Lines 1019-1025 Link Here
1019
                // In an imported file (and not completely
1019
                // In an imported file (and not completely
1020
                // ignoring the project tag or having a preconfigured prefix)
1020
                // ignoring the project tag or having a preconfigured prefix)
1021
                String newName = prefix + sep + name;
1021
                String newName = prefix + sep + name;
1022
                Target newTarget = usedTarget ? new Target(target) : target;
1022
                Target clonedTarget = "target".equals(tag)
1023
                    ? new Target(target) : new ExtensionPoint(target);
1024
            
1025
                Target newTarget = usedTarget ? clonedTarget : target;
1023
                newTarget.setName(newName);
1026
                newTarget.setName(newName);
1024
                context.getCurrentTargets().put(newName, newTarget);
1027
                context.getCurrentTargets().put(newName, newTarget);
1025
                project.addOrReplaceTarget(newName, newTarget);
1028
                project.addOrReplaceTarget(newName, newTarget);
(-)src/main/org/apache/tools/ant/ExtensionPoint.java (-3 / +14 lines)
Lines 25-33 Link Here
25
 */
25
 */
26
public class ExtensionPoint extends Target {
26
public class ExtensionPoint extends Target {
27
27
28
    // no "clone" constructor since I'm not really sure where it is
28
    public ExtensionPoint() {
29
    // used
30
29
30
    }
31
32
    /**
33
     * Cloning constructor.
34
     * @param other the Target to clone.
35
     */
36
    public ExtensionPoint(Target other) {
37
        //Should we have a clone constructor taking an ExtensionPoint as parameter?
38
        super(other);
39
    }
40
41
31
    private static final String NO_CHILDREN_ALLOWED
42
    private static final String NO_CHILDREN_ALLOWED
32
        = "you must not nest child elements into an extension-point";
43
        = "you must not nest child elements into an extension-point";
33
44
Lines 45-48 Link Here
45
        throw new BuildException(NO_CHILDREN_ALLOWED);
56
        throw new BuildException(NO_CHILDREN_ALLOWED);
46
    }
57
    }
47
    
58
    
48
}
59
}

Return to bug 53405