From 193ff8a349ba6b5f9cddb79a82c41cdb2209a28b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 30 Nov 2000 17:27:54 +0000 Subject: [PATCH] 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 --- WHATSNEW | 3 +++ .../org/apache/tools/ant/ProjectHelper.java | 26 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index ff9990227..df0e30b0e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -63,6 +63,9 @@ Fixed bugs: * org.apache.tools.mail.MailMessage (and therefore ) can now handle SMTP servers sending multi line responses. +* nested elements of now work for s not + nested into as well. + Changes from Ant 1.1 to Ant 1.2 =============================== diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 0d86d8645..6affa21e9 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -223,6 +223,12 @@ public class ProjectHelper { * Handler for the top level "project" element. */ 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) { super(parentHandler); } @@ -291,11 +297,13 @@ public class ProjectHelper { } 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 { - 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 { @@ -305,6 +313,15 @@ public class ProjectHelper { private void handleDataType(String name, AttributeList attrs) throws SAXParseException { 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 { task.init(); configure(task, attrs, project); + } + } + + public void finished() { + if (task != null && target == null) { task.execute(); } }