@Test void unwrapFromTwoSubDir(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); final File subDir = createDir(createDir(extractDir, "azul"), "v1.8_242"); createJvmFilesIn(subDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }
static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } }
ExtractUtil { static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } } }
ExtractUtil { static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } }  }
ExtractUtil { static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } }  static void unZip(final InputStream inputStream, final Path baseDir); static void unTar(final InputStream inputStream, final Path baseDir); static void unTarGzip(final InputStream inputStream, final Path baseDir); }
ExtractUtil { static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } }  static void unZip(final InputStream inputStream, final Path baseDir); static void unTar(final InputStream inputStream, final Path baseDir); static void unTarGzip(final InputStream inputStream, final Path baseDir);  }