Browse Source

macrodef element names are case insensentive due to use of DynamicConfigurator

PR: 26225
Reported by: John Sichi


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275929 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 21 years ago
parent
commit
af0809b04d
5 changed files with 26 additions and 2 deletions
  1. +3
    -0
      docs/manual/CoreTasks/macrodef.html
  2. +15
    -0
      src/etc/testcases/taskdefs/macrodef.xml
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
  5. +6
    -0
      src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java

+ 3
- 0
docs/manual/CoreTasks/macrodef.html View File

@@ -98,6 +98,9 @@
The contents of the nested elements of the task instance The contents of the nested elements of the task instance
are placed in the templated task at the tag name. are placed in the templated task at the tag name.
</p> </p>
<p>
The case of the element name is ignored.
</p>
<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>


+ 15
- 0
src/etc/testcases/taskdefs/macrodef.xml View File

@@ -86,4 +86,19 @@
<ignore myattribute="a"/> <ignore myattribute="a"/>
<ignore Myattribute="b"/> <ignore Myattribute="b"/>
</target> </target>

<target name="ignore-element-case">
<macrodef name="ignore">
<element name="MyElement"/>
<sequential>
<myElement/>
<MyElEmEnT/>
</sequential>
</macrodef>
<ignore>
<MYELEMENT>
<echo>nested element</echo>
</MYELEMENT>
</ignore>
</target>
</project> </project>

+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -395,7 +395,7 @@ public class MacroDef extends AntlibDefinition {
throw new BuildException( throw new BuildException(
"Illegal name [" + name + "] for attribute"); "Illegal name [" + name + "] for attribute");
} }
this.name = name;
this.name = name.toLowerCase(Locale.US);
} }


/** /**


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/MacroInstance.java View File

@@ -277,7 +277,7 @@ public class MacroInstance extends Task implements DynamicConfigurator {
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement(); RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement();
UnknownElement unknownElement = (UnknownElement) r.getProxy(); UnknownElement unknownElement = (UnknownElement) r.getProxy();
String tag = unknownElement.getTaskType();
String tag = unknownElement.getTaskType().toLowerCase(Locale.US);
MacroDef.TemplateElement templateElement = MacroDef.TemplateElement templateElement =
(MacroDef.TemplateElement) getNsElements().get(tag); (MacroDef.TemplateElement) getNsElements().get(tag);
if (templateElement == null) { if (templateElement == null) {


+ 6
- 0
src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java View File

@@ -109,5 +109,11 @@ public class MacroDefTest extends BuildFileTest {
"ignorecase", "ignorecase",
"a is ab is b"); "a is ab is b");
} }

public void testIgnoreElementCase() {
expectLog(
"ignore-element-case",
"nested elementnested element");
}
} }



Loading…
Cancel
Save