Browse Source

don't warn about duplicate project names if importing the same URL twice. PR 49162

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@936784 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
2c468c2121
2 changed files with 28 additions and 6 deletions
  1. +23
    -6
      src/main/org/apache/tools/ant/helper/ProjectHelper2.java
  2. +5
    -0
      src/tests/antunit/taskdefs/import-url-test.xml

+ 23
- 6
src/main/org/apache/tools/ant/helper/ProjectHelper2.java View File

@@ -760,17 +760,34 @@ public class ProjectHelper2 extends ProjectHelper {
String antFileProp =
MagicNames.ANT_FILE + "." + context.getCurrentProjectName();
String dup = project.getProperty(antFileProp);
String typeProp =
MagicNames.ANT_FILE_TYPE + "." + context.getCurrentProjectName();
String dupType = project.getProperty(typeProp);
if (dup != null && nameAttributeSet) {
File dupFile = new File(dup);
if (context.isIgnoringProjectTag() && !dupFile.equals(context.getBuildFile())) {
Object dupFile = null;
Object contextFile = null;
if (MagicNames.ANT_FILE_TYPE_URL.equals(dupType)) {
try {
dupFile = new URL(dup);
} catch (java.net.MalformedURLException mue) {
throw new BuildException("failed to parse "
+ dup + " as URL while looking"
+ " at a duplicate project"
+ " name.", mue);
}
contextFile = context.getBuildFileURL();
} else {
dupFile = new File(dup);
contextFile = context.getBuildFile();
}

if (context.isIgnoringProjectTag() && !dupFile.equals(contextFile)) {
project.log("Duplicated project name in import. Project "
+ context.getCurrentProjectName() + " defined first in " + dup
+ " and again in " + context.getBuildFile(), Project.MSG_WARN);
+ " and again in " + contextFile, Project.MSG_WARN);
}
}
if (nameAttributeSet) {
String typeProp = MagicNames.ANT_FILE_TYPE + "."
+ context.getCurrentProjectName();
if (context.getBuildFile() != null) {
project.setUserProperty(antFileProp,
context.getBuildFile().toString());
@@ -921,7 +938,7 @@ public class ProjectHelper2 extends ProjectHelper {
prefix = getTargetPrefix(context);
if (prefix == null) {
throw new BuildException("can't include build file "
+ context.getBuildFile()
+ context.getBuildFileURL()
+ ", no as attribute has been given"
+ " and the project tag doesn't"
+ " specify a name attribute");


+ 5
- 0
src/tests/antunit/taskdefs/import-url-test.xml View File

@@ -46,6 +46,11 @@ foo=bar
</jar>
<delete dir="${input}"/>

<import>
<javaresource name="a/b/outer.xml">
<classpath location="${test.jar}"/>
</javaresource>
</import>
<import>
<javaresource name="a/b/outer.xml">
<classpath location="${test.jar}"/>


Loading…
Cancel
Save