Skip to content

Commit

Permalink
Merge pull request #41888 from geoand/#41797
Browse files Browse the repository at this point in the history
Fix issue with Jib and mutable jar rebuild
  • Loading branch information
gsmet authored Jul 23, 2024
2 parents 70d4c12 + 18ab787 commit 6e4b804
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> effectiveJvmArguments = determineEffectiveJvmArguments(jibConfig, appCDSResult);
List<String> effectiveJvmArguments = determineEffectiveJvmArguments(jibConfig, appCDSResult, isMutableJar);
List<String> argsList = new ArrayList<>(3 + effectiveJvmArguments.size());
argsList.add("java");
argsList.addAll(effectiveJvmArguments);
Expand Down Expand Up @@ -693,7 +694,8 @@ private void mayInheritEntrypoint(JibContainerBuilder jibContainerBuilder, List<
}

private List<String> determineEffectiveJvmArguments(ContainerImageJibConfig jibConfig,
Optional<AppCDSResultBuildItem> appCDSResult) {
Optional<AppCDSResultBuildItem> appCDSResult,
boolean isMutableJar) {
List<String> effectiveJvmArguments = new ArrayList<>(jibConfig.jvmArguments);
jibConfig.jvmAdditionalArguments.ifPresent(effectiveJvmArguments::addAll);
if (appCDSResult.isPresent()) {
Expand All @@ -708,6 +710,10 @@ private List<String> 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;
}

Expand Down Expand Up @@ -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());
}

Expand Down

0 comments on commit 6e4b804

Please sign in to comment.