ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r955909 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Date Fri, 18 Jun 2010 09:37:07 GMT
Author: bodewig
Date: Fri Jun 18 09:37:07 2010
New Revision: 955909

URL: http://svn.apache.org/viewvc?rev=955909&view=rev
Log:
don't warn about multiple versions of Ant if the CLASSPATH entries really point to the same
JAR.  PR 49041

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=955909&r1=955908&r2=955909&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jun 18 09:37:07 2010
@@ -71,6 +71,11 @@ Fixed bugs:
  * <junitreport> did not handle encodings well for stdout/stderr.
    Bugzilla Report 49418.
 
+ * <junit> could issue a warning about multiple versions of Ant on the
+   CLASSPATH if two CLASSPATH entries differed in case on a
+   case-insensitive file system.
+   Bugzilla Report 49041.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=955909&r1=955908&r2=955909&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Fri
Jun 18 09:37:07 2010
@@ -1145,7 +1145,7 @@ public class JUnitTask extends Task {
                 for (Enumeration e = loader.getResources(projectResourceName);
                      e.hasMoreElements();) {
                     URL current = (URL) e.nextElement();
-                    if (previous != null && !current.equals(previous)) {
+                    if (previous != null && !urlEquals(current, previous)) {
                         log("WARNING: multiple versions of ant detected "
                             + "in path for junit "
                             + LINE_SEP + "         " + previous
@@ -1166,6 +1166,30 @@ public class JUnitTask extends Task {
     }
 
     /**
+     * Compares URLs for equality but takes case-sensitivity into
+     * account when comparing file URLs and ignores the jar specific
+     * part of the URL if present.
+     */
+    private static boolean urlEquals(URL u1, URL u2) {
+        String url1 = maybeStripJarAndClass(u1);
+        String url2 = maybeStripJarAndClass(u2);
+        if (url1.startsWith("file:") && url2.startsWith("file:")) {
+            return new File(FILE_UTILS.fromURI(url1))
+                .equals(new File(FILE_UTILS.fromURI(url2)));
+        }
+        return u1.equals(u2);
+    }
+
+    private static String maybeStripJarAndClass(URL u) {
+        String s = u.toString();
+        if (s.startsWith("jar:")) {
+            int pling = s.indexOf("!");
+            s = s.substring(4, pling == -1 ? s.length() : pling);
+        }
+        return s;
+    }
+
+    /**
      * Create a temporary file to pass the properties to a new process.
      * Will auto-delete on (graceful) exit.
      * The file will be in the project basedir unless tmpDir declares



Mime
View raw message