70
70
final class FromParams {
71
71
72
72
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 {
75
81
76
82
final var appBuilder = new ApplicationBuilder ();
77
83
@@ -85,8 +91,13 @@ static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> p
85
91
86
92
final var isRuntimeInstaller = isRuntimeInstaller (params );
87
93
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
+
88
99
if (isRuntimeInstaller ) {
89
- appBuilder .appImageLayout (RuntimeLayout . DEFAULT );
100
+ appBuilder .appImageLayout (predefinedRuntimeLayout . orElseThrow () );
90
101
} else {
91
102
appBuilder .appImageLayout (appLayout );
92
103
@@ -103,8 +114,7 @@ static ApplicationBuilder createApplicationBuilder(Map<String, ? super Object> p
103
114
104
115
MODULE_PATH .copyInto (params , runtimeBuilderBuilder ::modulePath );
105
116
106
- final var predefinedRuntimeImage = PREDEFINED_RUNTIME_IMAGE .findIn (params );
107
- predefinedRuntimeImage .ifPresentOrElse (runtimeBuilderBuilder ::forRuntime , () -> {
117
+ predefinedRuntimeDirectory .ifPresentOrElse (runtimeBuilderBuilder ::forRuntime , () -> {
108
118
final var startupInfos = launchers .asList ().stream ()
109
119
.map (Launcher ::startupInfo )
110
120
.map (Optional ::orElseThrow ).toList ();
0 commit comments