ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r936784 - in /ant/core/trunk/src: main/org/apache/tools/ant/helper/ProjectHelper2.java tests/antunit/taskdefs/import-url-test.xml
Date Thu, 22 Apr 2010 11:18:08 GMT
Author: bodewig
Date: Thu Apr 22 11:18:08 2010
New Revision: 936784

URL: http://svn.apache.org/viewvc?rev=936784&view=rev
Log:
don't warn about duplicate project names if importing the same URL twice.  PR 49162

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
    ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml

Modified: ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java?rev=936784&r1=936783&r2=936784&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/helper/ProjectHelper2.java Thu Apr 22 11:18:08
2010
@@ -760,17 +760,34 @@ public class ProjectHelper2 extends Proj
             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 Proj
                 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");

Modified: ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml?rev=936784&r1=936783&r2=936784&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/import-url-test.xml Thu Apr 22 11:18:08 2010
@@ -51,6 +51,11 @@ foo=bar
       <classpath location="${test.jar}"/>
     </javaresource>
   </import>
+  <import>
+    <javaresource name="a/b/outer.xml">
+      <classpath location="${test.jar}"/>
+    </javaresource>
+  </import>
 
   <target name="testImportOfNestedFile" depends="foo">
     <au:assertLogContains text="In inner"/>



Mime
View raw message