From c39f7f3091dee4b976be6ff617e2ac74becec4f3 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Tue, 31 Dec 2002 17:33:58 +0000 Subject: [PATCH] Added back the import property. Added a small message to allow debugging of duplicated project names. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273733 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/helper/ProjectHelper2.java | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index dec1b85f8..0902dd902 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -100,6 +100,7 @@ public class ProjectHelper2 extends ProjectHelper { throws BuildException { this.getImportStack().addElement(source); + //System.out.println("Adding " + source); AntXmlContext context=null; context=(AntXmlContext)project.getReference("ant.parsing.context"); // System.out.println("Parsing " + getImportStack().size() + " " + @@ -578,10 +579,21 @@ public class ProjectHelper2 extends ProjectHelper { Project project=context.getProject(); + /** XXX I really don't like this - the XML processor is still + * too 'involved' in the processing. A better solution (IMO) + * would be to create UE for Project and Target too, and + * then process the tree and have Project/Target deal with + * its attributes ( similar with Description ). + * + * If we eventually switch to ( or add support for ) DOM, + * things will work smoothly - UE can be avoided almost completely + * ( it could still be created on demand, for backward compat ) + */ + for (int i = 0; i < attrs.getLength(); i++) { String key = attrs.getQName(i); String value = attrs.getValue(i); - + if (key.equals("default")) { if ( value != null && !value.equals("")) { if( !context.ignoreProjectTag ) @@ -594,7 +606,7 @@ public class ProjectHelper2 extends ProjectHelper { if( !context.ignoreProjectTag ) { project.setName(value); project.addReference(value, project); - } + } } } else if (key.equals("id")) { if (value != null) { @@ -612,6 +624,21 @@ public class ProjectHelper2 extends ProjectHelper { } } + // XXX Move to Project ( so it is shared by all helpers ) + String antFileProp="ant.file." + context.currentProjectName; + String dup=project.getProperty(antFileProp); + if( dup!=null ) { + project.log("Duplicated project name in import. Project "+ + context.currentProjectName + " defined first in " + + dup + " and again in " + context.buildFile, + Project.MSG_WARN); + } + + if( context.buildFile != null ) { + project.setUserProperty("ant.file."+context.currentProjectName, + context.buildFile.toString()); + } + if( context.ignoreProjectTag ) { // no further processing return; @@ -633,7 +660,7 @@ public class ProjectHelper2 extends ProjectHelper { } } } - + project.addTarget("", context.implicitTarget); context.currentTarget=context.implicitTarget; }