From 0cbed2c7572e5b9dd34c10206fbecda7e72135b2 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Thu, 22 Nov 2012 23:45:18 +0100 Subject: [PATCH] Fix codegen when using SureFire Booter combined with JaCoCo When using codegen with SureFire Booter + JaCoCo, codegen was unable to determine the correct classpath, as its check for SureFire Booter was too strict (both the surefirebooter and jacoco jars were on the cp, while the code was only expecting surefirebooter). Fix this in a more generic way by checking all classloader URLs for surefirebooter. --- .../java/com/mysema/codegen/SimpleCompiler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mysema/codegen/SimpleCompiler.java b/src/main/java/com/mysema/codegen/SimpleCompiler.java index b4d62d3a2..ff91c8fa4 100644 --- a/src/main/java/com/mysema/codegen/SimpleCompiler.java +++ b/src/main/java/com/mysema/codegen/SimpleCompiler.java @@ -41,11 +41,21 @@ import com.google.common.base.Joiner; public class SimpleCompiler implements JavaCompiler { private static final Joiner pathJoiner = Joiner.on(File.pathSeparator); - + + private static boolean isSureFireBooter(URLClassLoader cl) { + for (URL url : cl.getURLs()) { + if (url.getPath().contains("surefirebooter")) { + return true; + } + } + + return false; + } + public static String getClassPath(URLClassLoader cl) { try { List paths = new ArrayList(); - if (cl.getURLs().length == 1 && cl.getURLs()[0].getPath().contains("surefirebooter")) { + if (isSureFireBooter(cl)) { // extract MANIFEST.MF Class-Path entry, since the Java Compiler doesn't handle // manifest only jars in the classpath correctly URL url = cl.findResource("META-INF/MANIFEST.MF");