List<Path> () { String jarsToRunTestsFrom = System.getProperty("jar.dependencies.to.tests"); if (jarsToRunTestsFrom != null) { String[] jars = jarsToRunTestsFrom.split(";"); List<Path> classpath = Objects.requireNonNull(ExternalClasspathClassLoader.getRoots()); List<Path> testPaths = Arrays.stream(jars) .map(jarName -> { List<Path> resultJars = ContainerUtil.filter(classpath, path -> path.getFileName().toString().startsWith(jarName)); if (resultJars.size() != 1) { String classpathPretty = classpath.stream().map(Path::toString).collect(Collectors.joining(File.pathSeparator)); throw new IllegalStateException( (resultJars.isEmpty() ? "Cannot find " : "More than one ") + jarName + " in " + classpathPretty ); } return resultJars.get(0); } ) .map(Path::normalize) .map(jar -> { try { if (!Files.exists(jar)) { throw new IllegalStateException(jar + " doesn't exist"); } String jarNameWithoutExtension = StringUtil.substringBefore(jar.getFileName().toString(), "."); Path out = Paths.get(PathManager.getHomePath(), "out", "jar-dependencies-to-test", jarNameWithoutExtension); new Decompressor.Zip(jar).extract(out); return out; } catch (IOException e) { throw new IllegalStateException(e); } }) .collect(Collectors.toList()); System.out.println("Collecting tests from roots specified by jar.dependencies.to.tests property: " + testPaths); return testPaths; } String testRoots = System.getProperty("test.roots"); if (testRoots != null) { System.out.println("Collecting tests from roots specified by test.roots property: " + testRoots); return ContainerUtil.map(testRoots.split(";"), Paths::get); } List<Path> roots = ExternalClasspathClassLoader.getRoots(); if (roots != null) { List<Path> excludeRoots = ExternalClasspathClassLoader.getExcludeRoots(); if (excludeRoots != null) { System.out.println("Skipping tests from " + excludeRoots.size() + " roots"); roots = new ArrayList<>(roots); roots.removeAll(FileCollectionFactory.createCanonicalPathSet(excludeRoots)); } System.out.println("Collecting tests from roots specified by classpath.file property: " + roots); return roots; } else { ClassLoader loader = TestAll.class.getClassLoader(); if (loader instanceof URLClassLoader) { return ContainerUtil.map(getClassRoots(((URLClassLoader)loader).getURLs()), url -> Paths.get(url.toUri())); } if (loader instanceof UrlClassLoader) { List<Path> urls = ((UrlClassLoader)loader).getBaseUrls(); System.out.println("Collecting tests from " + urls); return urls; } return ContainerUtil.map(System.getProperty("java.class.path").split(File.pathSeparator), Paths::get); } }