diff --git a/pitest/src/main/java/org/pitest/classpath/ClassPath.java b/pitest/src/main/java/org/pitest/classpath/ClassPath.java index c1832f2e8..053ff64e3 100644 --- a/pitest/src/main/java/org/pitest/classpath/ClassPath.java +++ b/pitest/src/main/java/org/pitest/classpath/ClassPath.java @@ -37,6 +37,8 @@ import org.pitest.util.PitError; import org.pitest.util.StreamUtil; +import static org.pitest.util.ManifestUtils.CLASSPATH_JAR_FILE_PREFIX; + public class ClassPath { private static final Logger LOG = Log.getLogger(); @@ -115,7 +117,7 @@ public URL findResource(final String name) { public static Collection getClassPathElementsAsPaths() { final Set filesAsString = new LinkedHashSet<>(); - FCollection.mapTo(getClassPathElementsAsFiles(), file -> file.getPath(), + FCollection.mapTo(getClassPathElementsAsFiles(), File::getPath, filesAsString); return filesAsString; } @@ -138,8 +140,8 @@ public static Collection getClassPathElementsAsFiles() { * @param elements existing elements */ private static void addEntriesFromClasspathManifest(final Set elements) { - Optional maybeJar = elements.stream().filter( f -> f.getName().startsWith("classpath") && f.getName().endsWith(".jar")) - .findFirst(); + Optional maybeJar = elements.stream().filter(f -> f.getName().startsWith(CLASSPATH_JAR_FILE_PREFIX) && f.getName().endsWith(".jar")) + .findFirst(); maybeJar.ifPresent(file -> elements.addAll(ManifestUtils.readClasspathManifest(file))); } diff --git a/pitest/src/main/java/org/pitest/util/ManifestUtils.java b/pitest/src/main/java/org/pitest/util/ManifestUtils.java index e36aac2b3..403fb7405 100644 --- a/pitest/src/main/java/org/pitest/util/ManifestUtils.java +++ b/pitest/src/main/java/org/pitest/util/ManifestUtils.java @@ -34,6 +34,8 @@ */ public class ManifestUtils { + public static final String CLASSPATH_JAR_FILE_PREFIX = "pitest-classpath-jar-file-"; + // Method based on // https://github.com/JetBrains/intellij-community/blob/master/java/java-runtime/src/com/intellij/rt/execution/testFrameworks/ForkedByModuleSplitter.java // JetBrains copyright notice and licence retained above. @@ -59,7 +61,7 @@ public static File createClasspathJarFile(String classpath) } attributes.put(Attributes.Name.CLASS_PATH, classpathForManifest.toString()); - File jarFile = File.createTempFile("classpath", ".jar"); + File jarFile = File.createTempFile(CLASSPATH_JAR_FILE_PREFIX, ".jar"); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile)); ZipOutputStream jarPlugin = new JarOutputStream(out, manifest); ) {