Skip to content

Commit 83fe9cc

Browse files
Tune FromParams.createApplicationBuilder() to work with macosx packages
1 parent 10cfba4 commit 83fe9cc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/jdk.jpackage/share/classes/jdk/jpackage/internal/FromParams.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@
7070
final class FromParams {
7171

7272
static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> params,
73-
Function<Map<String, ? super Object>, Launcher> launcherMapper, ApplicationLayout appLayout)
74-
throws ConfigException, IOException {
73+
Function<Map<String, ? super Object>, Launcher> launcherMapper,
74+
ApplicationLayout appLayout) throws ConfigException, IOException {
75+
return createApplicationBuilder(params, launcherMapper, appLayout, Optional.of(RuntimeLayout.DEFAULT));
76+
}
77+
78+
static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> params,
79+
Function<Map<String, ? super Object>, Launcher> launcherMapper,
80+
ApplicationLayout appLayout, Optional<RuntimeLayout> predefinedRuntimeLayout) throws ConfigException, IOException {
7581

7682
final var appBuilder = new ApplicationBuilder();
7783

@@ -85,8 +91,13 @@ static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> p
8591

8692
final var isRuntimeInstaller = isRuntimeInstaller(params);
8793

94+
final var predefinedRuntimeImage = PREDEFINED_RUNTIME_IMAGE.findIn(params);
95+
96+
final var predefinedRuntimeDirectory = predefinedRuntimeLayout.flatMap(
97+
layout -> predefinedRuntimeImage.map(layout::resolveAt)).map(RuntimeLayout::runtimeDirectory);
98+
8899
if (isRuntimeInstaller) {
89-
appBuilder.appImageLayout(RuntimeLayout.DEFAULT);
100+
appBuilder.appImageLayout(predefinedRuntimeLayout.orElseThrow());
90101
} else {
91102
appBuilder.appImageLayout(appLayout);
92103

@@ -103,8 +114,7 @@ static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> p
103114

104115
MODULE_PATH.copyInto(params, runtimeBuilderBuilder::modulePath);
105116

106-
final var predefinedRuntimeImage = PREDEFINED_RUNTIME_IMAGE.findIn(params);
107-
predefinedRuntimeImage.ifPresentOrElse(runtimeBuilderBuilder::forRuntime, () -> {
117+
predefinedRuntimeDirectory.ifPresentOrElse(runtimeBuilderBuilder::forRuntime, () -> {
108118
final var startupInfos = launchers.asList().stream()
109119
.map(Launcher::startupInfo)
110120
.map(Optional::orElseThrow).toList();

0 commit comments

Comments
 (0)