Browse Source

only treat tasks as tasks if they are children of TaskContainers.

PR: 3693


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269840 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
3a2956ada2
1 changed files with 29 additions and 3 deletions
  1. +29
    -3
      src/main/org/apache/tools/ant/UnknownElement.java

+ 29
- 3
src/main/org/apache/tools/ant/UnknownElement.java View File

@@ -64,8 +64,20 @@ import java.util.Vector;
*/
public class UnknownElement extends Task {

/**
* Holds the name of the task or nested child element of a task
* that hasn't been defined at parser time.
*/
private String elementName;

/**
* The task after it has been loaded.
*/
private Task realTask;

/**
* Childelements, holds UnknownElement instances.
*/
private Vector children = new Vector();
public UnknownElement (String elementName) {
@@ -73,12 +85,16 @@ public class UnknownElement extends Task {
}
/**
* return the corresponding XML tag.
* return the corresponding XML element name.
*/
public String getTag() {
return elementName;
}

/**
* creates the task instance, creates child elements, configures
* the attributes of the task.
*/
public void maybeConfigure() throws BuildException {
realTask = makeTask(this, wrapper);

@@ -105,10 +121,17 @@ public class UnknownElement extends Task {
realTask.perform();
}

/**
* Adds a child element to this element.
*/
public void addChild(UnknownElement child) {
children.addElement(child);
}

/**
* Creates child elements, creates children of the children, sets
* attributes of the child elements.
*/
protected void handleChildren(Object parent,
RuntimeConfigurable parentWrapper)
throws BuildException {
@@ -124,6 +147,7 @@ public class UnknownElement extends Task {
RuntimeConfigurable childWrapper = parentWrapper.getChild(i);
UnknownElement child = (UnknownElement) children.elementAt(i);
Object realChild = null;

if (parent instanceof TaskContainer) {
realChild = makeTask(child, childWrapper);
((TaskContainer) parent).addTask((Task) realChild);
@@ -132,11 +156,13 @@ public class UnknownElement extends Task {
}

childWrapper.setProxy(realChild);
if (realChild instanceof Task) {
if (parent instanceof TaskContainer) {
((Task) realChild).setRuntimeConfigurableWrapper(childWrapper);
}

child.handleChildren(realChild, childWrapper);
if (realChild instanceof Task) {

if (parent instanceof TaskContainer) {
((Task) realChild).maybeConfigure();
}
}


Loading…
Cancel
Save