From 18ab7879d231fec464574767b6022ad5373e356b Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 15 Jul 2024 11:00:49 +0300 Subject: [PATCH] Fix issue with Jib and mutable jar rebuild Fixes: #41797 --- .../image/jib/deployment/JibProcessor.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java index 44b3a109c820e..38d9bf90817ad 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java @@ -453,9 +453,10 @@ private JibContainerBuilder createContainerBuilderFromFastJar(String baseJvmImag entrypoint = List.of(RUN_JAVA_PATH); envVars.put("JAVA_APP_JAR", workDirInContainer + "/" + JarResultBuildStep.QUARKUS_RUN_JAR); envVars.put("JAVA_APP_DIR", workDirInContainer.toString()); - envVars.put("JAVA_OPTS_APPEND", String.join(" ", determineEffectiveJvmArguments(jibConfig, appCDSResult))); + envVars.put("JAVA_OPTS_APPEND", + String.join(" ", determineEffectiveJvmArguments(jibConfig, appCDSResult, isMutableJar))); } else { - List effectiveJvmArguments = determineEffectiveJvmArguments(jibConfig, appCDSResult); + List effectiveJvmArguments = determineEffectiveJvmArguments(jibConfig, appCDSResult, isMutableJar); List argsList = new ArrayList<>(3 + effectiveJvmArguments.size()); argsList.add("java"); argsList.addAll(effectiveJvmArguments); @@ -693,7 +694,8 @@ private void mayInheritEntrypoint(JibContainerBuilder jibContainerBuilder, List< } private List determineEffectiveJvmArguments(ContainerImageJibConfig jibConfig, - Optional appCDSResult) { + Optional appCDSResult, + boolean isMutableJar) { List effectiveJvmArguments = new ArrayList<>(jibConfig.jvmArguments); jibConfig.jvmAdditionalArguments.ifPresent(effectiveJvmArguments::addAll); if (appCDSResult.isPresent()) { @@ -708,6 +710,10 @@ private List determineEffectiveJvmArguments(ContainerImageJibConfig jibC effectiveJvmArguments.add("-XX:SharedArchiveFile=" + appCDSResult.get().getAppCDS().getFileName().toString()); } } + if (isMutableJar) { + // see https://github.com/quarkusio/quarkus/issues/41797 + effectiveJvmArguments.add("-Dquarkus.package.output-directory=${PWD}"); + } return effectiveJvmArguments; } @@ -746,7 +752,7 @@ private JibContainerBuilder createContainerBuilderFromLegacyJar(String baseJvmIm // when there is no custom entry point, we just set everything up for a regular java run if (!jibConfig.jvmEntrypoint.isPresent()) { javaContainerBuilder - .addJvmFlags(determineEffectiveJvmArguments(jibConfig, Optional.empty())) + .addJvmFlags(determineEffectiveJvmArguments(jibConfig, Optional.empty(), false)) .setMainClass(mainClassBuildItem.getClassName()); }