Browse Source

don't warn about multiple versions of Ant if the CLASSPATH entries really point to the same JAR. PR 49041

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@955909 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
047941f031
2 changed files with 30 additions and 1 deletions
  1. +5
    -0
      WHATSNEW
  2. +25
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 5
- 0
WHATSNEW View File

@@ -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:
--------------



+ 25
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -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
@@ -1165,6 +1165,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.


Loading…
Cancel
Save