Browse Source

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
master
Costin Manolache 22 years ago
parent
commit
c39f7f3091
1 changed files with 30 additions and 3 deletions
  1. +30
    -3
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java

+ 30
- 3
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -100,6 +100,7 @@ public class ProjectHelper2 extends ProjectHelper {
throws BuildException throws BuildException
{ {
this.getImportStack().addElement(source); this.getImportStack().addElement(source);
//System.out.println("Adding " + source);
AntXmlContext context=null; AntXmlContext context=null;
context=(AntXmlContext)project.getReference("ant.parsing.context"); context=(AntXmlContext)project.getReference("ant.parsing.context");
// System.out.println("Parsing " + getImportStack().size() + " " + // System.out.println("Parsing " + getImportStack().size() + " " +
@@ -578,10 +579,21 @@ public class ProjectHelper2 extends ProjectHelper {


Project project=context.getProject(); 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++) { for (int i = 0; i < attrs.getLength(); i++) {
String key = attrs.getQName(i); String key = attrs.getQName(i);
String value = attrs.getValue(i); String value = attrs.getValue(i);
if (key.equals("default")) { if (key.equals("default")) {
if ( value != null && !value.equals("")) { if ( value != null && !value.equals("")) {
if( !context.ignoreProjectTag ) if( !context.ignoreProjectTag )
@@ -594,7 +606,7 @@ public class ProjectHelper2 extends ProjectHelper {
if( !context.ignoreProjectTag ) { if( !context.ignoreProjectTag ) {
project.setName(value); project.setName(value);
project.addReference(value, project); project.addReference(value, project);
}
}
} }
} else if (key.equals("id")) { } else if (key.equals("id")) {
if (value != null) { 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 ) { if( context.ignoreProjectTag ) {
// no further processing // no further processing
return; return;
@@ -633,7 +660,7 @@ public class ProjectHelper2 extends ProjectHelper {
} }
} }
} }
project.addTarget("", context.implicitTarget); project.addTarget("", context.implicitTarget);
context.currentTarget=context.implicitTarget; context.currentTarget=context.implicitTarget;
} }


Loading…
Cancel
Save