From f15fb7639cb643c876f15a87659cf4a068689a33 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Fri, 27 Dec 2002 18:14:50 +0000 Subject: [PATCH] Update with the 2 changes: set attributes explicitely ( instead of passing the SAX2 Attributes). - import will use the normal entry point and will not depend on the sax context. We know we are in an import by looking at the importStack, that will set ignoreProjectTag flag and we'll reuse the context. There are few more changes needed to clean up the context ( some fields are no longer needed, and it needs to use proper getter/setters instead of the fields ). git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273705 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/helper/ProjectHelper2.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index 122f34b27..dec1b85f8 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -99,15 +99,27 @@ public class ProjectHelper2 extends ProjectHelper { public void parse(Project project, Object source) throws BuildException { - AntXmlContext context=new AntXmlContext(project, this); - - project.addReference( "ant.parsing.context", context ); - project.addReference( "ant.targets", context.targetVector ); - - parse(project, source,new RootHandler(context)); - - // Execute the top-level target - context.implicitTarget.execute(); + this.getImportStack().addElement(source); + AntXmlContext context=null; + context=(AntXmlContext)project.getReference("ant.parsing.context"); +// System.out.println("Parsing " + getImportStack().size() + " " + +// context+ " " + getImportStack() ); + if( context==null ) { + context=new AntXmlContext(project, this); + project.addReference( "ant.parsing.context", context ); + project.addReference( "ant.targets", context.targetVector ); + } + + if( this.getImportStack().size() > 1 ) { + // we are in an imported file. + context.ignoreProjectTag=true; + parse(project, source, new RootHandler(context)); + } else { + // top level file + parse(project, source,new RootHandler(context)); + // Execute the top-level target + context.implicitTarget.execute(); + } } /** @@ -858,7 +870,11 @@ public class ProjectHelper2 extends ProjectHelper { // This is a nop in UE: task.init(); wrapper=new RuntimeConfigurable( task, task.getTaskName()); - wrapper.setAttributes2(attrs); + + for (int i = 0; i < attrs.getLength(); i++) { + wrapper.setAttribute( attrs.getQName(i), + attrs.getValue(i)); + } if (parentWrapper != null) { parentWrapper.addChild(wrapper);