Browse Source

Make task replacements recreate their child elements when they get redefined.

PR: 10904

This should also fix the Axis build failure Sam has reported.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273144 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
aa07dd4611
3 changed files with 35 additions and 0 deletions
  1. +2
    -0
      WHATSNEW
  2. +9
    -0
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  3. +24
    -0
      src/main/org/apache/tools/ant/Task.java

+ 2
- 0
WHATSNEW View File

@@ -21,6 +21,8 @@ Fixed bugs:
* The ExpandProperties filter threw NPEs when defined using
the <filterreader> format.

* If a task got redefined via <taskdef>, it lost its child elements.

Other changes:
--------------



+ 9
- 0
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -148,6 +148,15 @@ public class RuntimeConfigurable {
return (RuntimeConfigurable) children.elementAt(index);
}

/**
* Returns an enumeration of all child wrappers.
*
* @since Ant 1.6
*/
Enumeration getChildren() {
return children.elements();
}

/**
* Adds characters from #PCDATA areas to the wrapped element.
*


+ 24
- 0
src/main/org/apache/tools/ant/Task.java View File

@@ -54,6 +54,8 @@

package org.apache.tools.ant;

import java.util.Enumeration;

/**
* Base class for all tasks.
*
@@ -372,9 +374,31 @@ public abstract class Task extends ProjectComponent {
replacement.setOwningTarget(target);
replacement.setRuntimeConfigurableWrapper(wrapper);
wrapper.setProxy(replacement);
replaceChildren(wrapper, replacement);
target.replaceChild(this, replacement);
replacement.maybeConfigure();
}
return replacement;
}

/**
* Recursively adds an UnknownElement instances for each child
* element of replacement.
*
* @since Ant 1.6
*/
private void replaceChildren(RuntimeConfigurable wrapper,
UnknownElement parentElement) {
Enumeration enum = wrapper.getChildren();
while (enum.hasMoreElements()) {
RuntimeConfigurable childWrapper =
(RuntimeConfigurable) enum.nextElement();
UnknownElement childElement =
new UnknownElement(childWrapper.getElementTag());
parentElement.addChild(childElement);
childElement.setRuntimeConfigurableWrapper(childWrapper);
childWrapper.setProxy(childElement);
replaceChildren(childWrapper, childElement);
}
}
}

Loading…
Cancel
Save