detect jar hell in tests better and fix more stuff
This commit is contained in:
parent
f8fbf1fa0c
commit
b58eb35dfa
|
@ -64,16 +64,23 @@ class JarHell {
|
||||||
while (elements.hasMoreElements()) {
|
while (elements.hasMoreElements()) {
|
||||||
String entry = elements.nextElement().getName();
|
String entry = elements.nextElement().getName();
|
||||||
if (entry.endsWith(".class")) {
|
if (entry.endsWith(".class")) {
|
||||||
|
// for jar format, the separator is defined as /
|
||||||
|
entry = entry.replace('/', '.').substring(0, entry.length() - 6);
|
||||||
checkClass(clazzes, entry, url);
|
checkClass(clazzes, entry, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Files.walkFileTree(PathUtils.get(url.toURI()), new SimpleFileVisitor<Path>() {
|
// case for tests: where we have class files in the classpath
|
||||||
|
final Path root = PathUtils.get(url.toURI());
|
||||||
|
final String sep = root.getFileSystem().getSeparator();
|
||||||
|
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
String entry = file.toString();
|
String entry = root.relativize(file).toString();
|
||||||
if (entry.endsWith(".class")) {
|
if (entry.endsWith(".class")) {
|
||||||
|
// normalize with the os separator
|
||||||
|
entry = entry.replace(sep, ".").substring(0, entry.length() - 6);
|
||||||
checkClass(clazzes, entry, url);
|
checkClass(clazzes, entry, url);
|
||||||
}
|
}
|
||||||
return super.visitFile(file, attrs);
|
return super.visitFile(file, attrs);
|
||||||
|
@ -85,10 +92,10 @@ class JarHell {
|
||||||
|
|
||||||
@SuppressForbidden(reason = "proper use of URL to reduce noise")
|
@SuppressForbidden(reason = "proper use of URL to reduce noise")
|
||||||
static void checkClass(Map<String,URL> clazzes, String clazz, URL url) {
|
static void checkClass(Map<String,URL> clazzes, String clazz, URL url) {
|
||||||
if (clazz.startsWith("org/apache/log4j")) {
|
if (clazz.startsWith("org.apache.log4j")) {
|
||||||
return; // go figure, jar hell for what should be System.out.println...
|
return; // go figure, jar hell for what should be System.out.println...
|
||||||
}
|
}
|
||||||
if (clazz.equals("org/joda/time/base/BaseDateTime.class")) {
|
if (clazz.equals("org.joda.time.base.BaseDateTime")) {
|
||||||
return; // apparently this is intentional... clean this up
|
return; // apparently this is intentional... clean this up
|
||||||
}
|
}
|
||||||
URL previous = clazzes.put(clazz, url);
|
URL previous = clazzes.put(clazz, url);
|
||||||
|
|
|
@ -44,6 +44,12 @@ governing permissions and limitations under the License. -->
|
||||||
<groupId>com.microsoft.azure</groupId>
|
<groupId>com.microsoft.azure</groupId>
|
||||||
<artifactId>azure-management-compute</artifactId>
|
<artifactId>azure-management-compute</artifactId>
|
||||||
<version>0.7.0</version>
|
<version>0.7.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>stax</groupId>
|
||||||
|
<artifactId>stax-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.microsoft.azure</groupId>
|
<groupId>com.microsoft.azure</groupId>
|
||||||
|
|
|
@ -43,6 +43,12 @@ governing permissions and limitations under the License. -->
|
||||||
<groupId>com.google.apis</groupId>
|
<groupId>com.google.apis</groupId>
|
||||||
<artifactId>google-api-services-compute</artifactId>
|
<artifactId>google-api-services-compute</artifactId>
|
||||||
<version>${google.gce.version}</version>
|
<version>${google.gce.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava-jdk5</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue