diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java index b1f90b4b0dd7a..6b557475c2258 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/JarResultBuildStep.java @@ -736,14 +736,25 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem, Path appInfo = buildDir.resolve(QuarkusEntryPoint.QUARKUS_APPLICATION_DAT); - // merge all the jars in boot into a single one - // the idea is to cut down on the memory needed to load them - List copiedBootJars = Files.list(bootLib) .filter(p -> p.getFileName().toString().endsWith(".jar")) .collect(Collectors.toList()); + Path initJar = buildDir.resolve(QUARKUS_RUN_JAR); + if (!rebuild) { + try (FileSystem runnerZipFs = ZipUtils.newZip(initJar)) { + ResolvedDependency appArtifact = curateOutcomeBuildItem.getApplicationModel().getAppArtifact(); + generateManifest(runnerZipFs, + "", + packageConfig, appArtifact, + QuarkusEntryPoint.class.getName(), + applicationInfo); + } + } + + // merge all the jars in boot into a single one + // the idea is to cut down on the memory needed to load them - mergeBootJars(packageConfig, bootLib, copiedBootJars, + mergeBootJars(packageConfig, initJar, copiedBootJars, parentFirstTargetPathToArtifact); try (OutputStream out = Files.newOutputStream(appInfo)) { @@ -773,14 +784,10 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem, throw new UncheckedIOException(e); } }); - - StringBuilder classPath = new StringBuilder(LIB + "/" + BOOT_LIB + "/" + MERGED_BOOT_LIB + ".jar"); - Files.list(bootLib).filter(p -> !p.getFileName().toString().contains(MERGED_BOOT_LIB)).forEach(p -> { - classPath.append(" " + LIB + "/" + BOOT_LIB + "/" + p.getFileName().toString()); - }); + Files.delete(bootLib); runnerJar.toFile().setReadable(true, false); - Path initJar = buildDir.resolve(QUARKUS_RUN_JAR); + boolean mutableJar = packageConfig.type.equalsIgnoreCase(PackageConfig.BuiltInType.MUTABLE_JAR.getValue()); if (mutableJar) { //we output the properties in a reproducible manner, so we remove the date comment @@ -797,14 +804,6 @@ private JarBuildItem buildThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem, } } if (!rebuild) { - try (FileSystem runnerZipFs = ZipUtils.newZip(initJar)) { - ResolvedDependency appArtifact = curateOutcomeBuildItem.getApplicationModel().getAppArtifact(); - generateManifest(runnerZipFs, - classPath.toString(), - packageConfig, appArtifact, - QuarkusEntryPoint.class.getName(), - applicationInfo); - } //now copy the deployment artifacts, if required if (mutableJar) { @@ -879,7 +878,7 @@ public void accept(Path path) { } private void mergeBootJars(PackageConfig packageConfig, - Path bootLib, List copiedBootJars, + Path initJar, List copiedBootJars, Map parentFirstTargetPathToArtifact) throws IOException { final Map seen = new HashMap<>(); final Map> duplicateCatcher = new HashMap<>(); @@ -894,8 +893,7 @@ public boolean test(String path) { } }; - Path mergedBootLibJar = bootLib.resolve(MERGED_BOOT_LIB + ".jar"); - try (FileSystem runnerZipFs = ZipUtils.newZip(mergedBootLibJar)) { + try (FileSystem runnerZipFs = ZipUtils.newFileSystem(initJar)) { Path manifestPath = runnerZipFs.getPath("META-INF", "MANIFEST.MF"); Manifest manifest = new Manifest(); Files.createDirectories(manifestPath.getParent()); @@ -1372,7 +1370,9 @@ private void generateManifest(FileSystem runnerZipFs, final String classPath, Pa log.warn( "A CLASS_PATH entry was already defined in your MANIFEST.MF or using the property quarkus.package.manifest.attributes.\"Class-Path\". Quarkus has overwritten this existing entry."); } - attributes.put(Attributes.Name.CLASS_PATH, classPath); + if (!((classPath == null) || classPath.isEmpty())) { + attributes.put(Attributes.Name.CLASS_PATH, classPath); + } if (attributes.containsKey(Attributes.Name.MAIN_CLASS)) { String existingMainClass = attributes.getValue(Attributes.Name.MAIN_CLASS); if (!mainClassName.equals(existingMainClass)) { diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/QuarkusEntryPoint.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/QuarkusEntryPoint.java index 0afc6b6ec1de0..2bac1659e380c 100644 --- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/QuarkusEntryPoint.java +++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/runner/QuarkusEntryPoint.java @@ -40,7 +40,7 @@ private static void doRun(Object args) throws IOException, ClassNotFoundExceptio InvocationTargetException, NoSuchMethodException { String path = QuarkusEntryPoint.class.getProtectionDomain().getCodeSource().getLocation().getPath(); String decodedPath = URLDecoder.decode(path, "UTF-8"); - Path appRoot = new File(decodedPath).toPath().getParent().getParent().getParent(); + Path appRoot = new File(decodedPath).toPath().getParent(); if (Boolean.parseBoolean(System.getenv("QUARKUS_LAUNCH_DEVMODE"))) { DevModeMediator.doDevMode(appRoot);