Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with Jib and mutable jar rebuild #41888

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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