keep backwards compatibility for all other cases (all "normal" nested element names get converted to lower case). PR: 19323 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274525 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -277,6 +277,7 @@ | |||
| <patternset id="teststhatfail"> | |||
| <exclude name="${optional.package}/BeanShellScriptTest.java"/> | |||
| <exclude name="${ant.package}/taskdefs/ImportTest.java"/> | |||
| <exclude name="${ant.package}/CaseTest.java"/> | |||
| </patternset> | |||
| <!-- | |||
| @@ -348,16 +348,29 @@ public class RuntimeConfigurable implements Serializable { | |||
| childTask.setRuntimeConfigurableWrapper(child); | |||
| } | |||
| if (configureChildren | |||
| && ih.supportsNestedElement(child.getElementTag())) { | |||
| child.maybeConfigure(p); | |||
| Object container = wrappedObject; | |||
| if (container instanceof TaskAdapter) { | |||
| container = ((TaskAdapter) container).getProxy(); | |||
| if (configureChildren) { | |||
| /* | |||
| * backwards compatibility - element names of nested | |||
| * elements have been all lower-case in Ant, except for | |||
| * TaskContainers | |||
| */ | |||
| /* XXX | |||
| * | |||
| * For some reason we don't throw an exception here if | |||
| * we find the nested element is unsupported, probably | |||
| * because this will happen somewhere else. | |||
| */ | |||
| String tag = child.getElementTag(); | |||
| if (ih.supportsNestedElement(tag.toLowerCase(Locale.US))) { | |||
| tag = tag.toLowerCase(Locale.US); | |||
| } else if (!ih.supportsNestedElement(tag)) { | |||
| continue; | |||
| } | |||
| ProjectHelper.storeChild(p, container, child.wrappedObject, | |||
| child.getElementTag() | |||
| .toLowerCase(Locale.US)); | |||
| child.maybeConfigure(p); | |||
| ProjectHelper.storeChild(p, target, child.wrappedObject, | |||
| tag); | |||
| } | |||
| } | |||
| @@ -54,6 +54,7 @@ | |||
| package org.apache.tools.ant; | |||
| import java.util.Locale; | |||
| import java.util.Vector; | |||
| import java.io.IOException; | |||
| @@ -273,26 +274,20 @@ public class UnknownElement extends Task { | |||
| UnknownElement child = (UnknownElement) children.elementAt(i); | |||
| Object realChild = null; | |||
| if (ih.supportsNestedElement(child.getTag())) { | |||
| realChild | |||
| = ih.createElement(getProject(), parent, child.getTag()); | |||
| childWrapper.setProxy(realChild); | |||
| if (realChild instanceof Task) { | |||
| Task childTask = (Task) realChild; | |||
| childTask.setRuntimeConfigurableWrapper(childWrapper); | |||
| childTask.setTaskName(child.getTag()); | |||
| childTask.setTaskType(child.getTag()); | |||
| } | |||
| child.handleChildren(realChild, childWrapper); | |||
| if (handleChild(ih, parent, child, | |||
| child.getTag().toLowerCase(Locale.US), | |||
| childWrapper)) { | |||
| } else if (!(parent instanceof TaskContainer)) { | |||
| ih.throwNotSupported(getProject(), parent, child.getTag()); | |||
| } else { | |||
| // a task container - anything could happen - just add the | |||
| // child to the container | |||
| TaskContainer container = (TaskContainer) parent; | |||
| container.addTask(child); | |||
| } | |||
| if (!handleChild(ih, parent, child, child.getTag(), | |||
| childWrapper)) { | |||
| // a task container - anything could happen - just add the | |||
| // child to the container | |||
| TaskContainer container = (TaskContainer) parent; | |||
| container.addTask(child); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -414,4 +409,31 @@ public class UnknownElement extends Task { | |||
| return null; | |||
| } | |||
| /** | |||
| * Try to create a nested element of <code>parent</code> for the | |||
| * given tag. | |||
| * | |||
| * @return whether the creation has been successful | |||
| */ | |||
| private boolean handleChild(IntrospectionHelper ih, | |||
| Object parent, UnknownElement child, | |||
| String childTag, | |||
| RuntimeConfigurable childWrapper) { | |||
| if (ih.supportsNestedElement(childTag)) { | |||
| Object realChild | |||
| = ih.createElement(getProject(), parent, childTag); | |||
| childWrapper.setProxy(realChild); | |||
| if (realChild instanceof Task) { | |||
| Task childTask = (Task) realChild; | |||
| childTask.setRuntimeConfigurableWrapper(childWrapper); | |||
| childTask.setTaskName(childTag); | |||
| childTask.setTaskType(childTag); | |||
| } | |||
| child.handleChildren(realChild, childWrapper); | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| }// UnknownElement | |||
| @@ -751,23 +751,6 @@ public class ProjectHelper2 extends ProjectHelper { | |||
| parent = parentWrapper.getProxy(); | |||
| } | |||
| if (parent != null) { | |||
| // nested elements. Backward compatibilitiy - only nested elements | |||
| // are lower cased in the original processor | |||
| qname = qname.toLowerCase(Locale.US); | |||
| // XXX What about nested elements that are inside TaskContainers ? | |||
| // We can't know that that we need lowercase until we know | |||
| // parent is not a TaskContainer. Maybe this test should | |||
| // be done in UnknownElement. | |||
| // Note: the original code seems to have a similar problem: the lowercase | |||
| // conversion happens only inside ProjectHelper, if we know that the | |||
| // parent is not TaskContainer. If the parent is not known - UE are used | |||
| // and AFAIK there is no code to deal with that, so the conversion will be | |||
| // different based on context ( if the enclosing task is taskdefed in target | |||
| // or known at top level ). | |||
| } | |||
| /* UnknownElement is used for tasks and data types - with | |||
| delayed eval */ | |||
| UnknownElement task = new UnknownElement(qname); | |||