Browse Source

Make sure, Taskdef.execute doesn't get called before the nested

elements have been configured.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268281 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
193ff8a349
2 changed files with 27 additions and 2 deletions
  1. +3
    -0
      WHATSNEW
  2. +24
    -2
      src/main/org/apache/tools/ant/ProjectHelper.java

+ 3
- 0
WHATSNEW View File

@@ -63,6 +63,9 @@ Fixed bugs:
* org.apache.tools.mail.MailMessage (and therefore <mail>) can now * org.apache.tools.mail.MailMessage (and therefore <mail>) can now
handle SMTP servers sending multi line responses. handle SMTP servers sending multi line responses.


* nested <classpath> elements of <taskdef> now work for <taskdef>s not
nested into <target> as well.

Changes from Ant 1.1 to Ant 1.2 Changes from Ant 1.1 to Ant 1.2
=============================== ===============================




+ 24
- 2
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -223,6 +223,12 @@ public class ProjectHelper {
* Handler for the top level "project" element. * Handler for the top level "project" element.
*/ */
private class ProjectHandler extends AbstractHandler { private class ProjectHandler extends AbstractHandler {
/**
* Tasks not living in a target need special processing
* in endElement (this is the right place to call execute).
*/
protected TaskHandler childHandler = null;

public ProjectHandler(DocumentHandler parentHandler) { public ProjectHandler(DocumentHandler parentHandler) {
super(parentHandler); super(parentHandler);
} }
@@ -291,11 +297,13 @@ public class ProjectHelper {
} }


private void handleTaskdef(String name, AttributeList attrs) throws SAXParseException { private void handleTaskdef(String name, AttributeList attrs) throws SAXParseException {
new TaskHandler(this, null).init(name, attrs);
childHandler = new TaskHandler(this, null);
childHandler.init(name, attrs);
} }


private void handleProperty(String name, AttributeList attrs) throws SAXParseException { private void handleProperty(String name, AttributeList attrs) throws SAXParseException {
new TaskHandler(this, null).init(name, attrs);
childHandler = new TaskHandler(this, null);
childHandler.init(name, attrs);
} }


private void handleTarget(String tag, AttributeList attrs) throws SAXParseException { private void handleTarget(String tag, AttributeList attrs) throws SAXParseException {
@@ -305,6 +313,15 @@ public class ProjectHelper {
private void handleDataType(String name, AttributeList attrs) throws SAXParseException { private void handleDataType(String name, AttributeList attrs) throws SAXParseException {
new DataTypeHandler(this).init(name, attrs); new DataTypeHandler(this).init(name, attrs);
} }

public void endElement(String name) throws SAXException {
if (childHandler != null) {
childHandler.finished();
childHandler = null;
}
super.endElement(name);
}
} }


/** /**
@@ -416,6 +433,11 @@ public class ProjectHelper {
} else { } else {
task.init(); task.init();
configure(task, attrs, project); configure(task, attrs, project);
}
}

public void finished() {
if (task != null && target == null) {
task.execute(); task.execute();
} }
} }


Loading…
Cancel
Save