@@ -149,43 +149,49 @@ data class JaunchConfig (
149
149
throw IllegalArgumentException (" Config versions are incompatible: ${config.jaunchVersion} != $jaunchVersion " )
150
150
}
151
151
return JaunchConfig (
152
+ // NB: when relevant, prefer values in the new config
152
153
jaunchVersion = config.jaunchVersion ? : jaunchVersion,
153
154
programName = config.programName ? : programName,
154
- includes = config.includes + includes,
155
- supportedOptions = config.supportedOptions + supportedOptions,
156
- osAliases = config.osAliases + osAliases,
157
- archAliases = config.archAliases + archAliases,
158
- modes = config.modes + modes,
159
- directives = config.directives + directives,
155
+ includes = merge( config.includes, includes) ,
156
+ supportedOptions = merge( config.supportedOptions, supportedOptions) ,
157
+ osAliases = merge( config.osAliases, osAliases) ,
158
+ archAliases = merge( config.archAliases, archAliases) ,
159
+ modes = merge( config.modes, modes) ,
160
+ directives = merge( config.directives, directives) ,
160
161
allowUnrecognizedArgs = config.allowUnrecognizedArgs ? : allowUnrecognizedArgs,
161
162
162
163
pythonEnabled = config.pythonEnabled ? : pythonEnabled,
163
- pythonRecognizedArgs = config.pythonRecognizedArgs + pythonRecognizedArgs,
164
- pythonRootPaths = config.pythonRootPaths + pythonRootPaths,
165
- pythonLibSuffixes = config.pythonLibSuffixes + pythonLibSuffixes,
164
+ pythonRecognizedArgs = merge( config.pythonRecognizedArgs, pythonRecognizedArgs) ,
165
+ pythonRootPaths = merge( config.pythonRootPaths, pythonRootPaths) ,
166
+ pythonLibSuffixes = merge( config.pythonLibSuffixes, pythonLibSuffixes) ,
166
167
pythonVersionMin = config.pythonVersionMin ? : pythonVersionMin,
167
168
pythonVersionMax = config.pythonVersionMax ? : pythonVersionMax,
168
- pythonPackages = config.pythonPackages + pythonPackages,
169
- pythonRuntimeArgs = config.pythonRuntimeArgs + pythonRuntimeArgs,
170
- pythonScriptPath = config.pythonScriptPath + pythonScriptPath,
171
- pythonMainArgs = config.pythonMainArgs + pythonMainArgs,
169
+ pythonPackages = merge( config.pythonPackages, pythonPackages) ,
170
+ pythonRuntimeArgs = merge( config.pythonRuntimeArgs, pythonRuntimeArgs) ,
171
+ pythonScriptPath = merge( config.pythonScriptPath, pythonScriptPath) ,
172
+ pythonMainArgs = merge( config.pythonMainArgs, pythonMainArgs) ,
172
173
173
174
jvmEnabled = config.jvmEnabled ? : jvmEnabled,
174
- jvmRecognizedArgs = config.jvmRecognizedArgs + jvmRecognizedArgs,
175
+ jvmRecognizedArgs = merge( config.jvmRecognizedArgs, jvmRecognizedArgs) ,
175
176
jvmAllowWeirdRuntimes = config.jvmAllowWeirdRuntimes ? : jvmAllowWeirdRuntimes,
176
177
jvmVersionMin = config.jvmVersionMin ? : jvmVersionMin,
177
178
jvmVersionMax = config.jvmVersionMax ? : jvmVersionMax,
178
- jvmDistrosAllowed = config.jvmDistrosAllowed + jvmDistrosAllowed,
179
- jvmDistrosBlocked = config.jvmDistrosBlocked + jvmDistrosBlocked,
180
- jvmRootPaths = config.jvmRootPaths + jvmRootPaths,
181
- jvmLibSuffixes = config.jvmLibSuffixes + jvmLibSuffixes,
182
- jvmClasspath = config.jvmClasspath + jvmClasspath,
179
+ jvmDistrosAllowed = merge( config.jvmDistrosAllowed, jvmDistrosAllowed) ,
180
+ jvmDistrosBlocked = merge( config.jvmDistrosBlocked, jvmDistrosBlocked) ,
181
+ jvmRootPaths = merge( config.jvmRootPaths, jvmRootPaths) ,
182
+ jvmLibSuffixes = merge( config.jvmLibSuffixes, jvmLibSuffixes) ,
183
+ jvmClasspath = merge( config.jvmClasspath, jvmClasspath) ,
183
184
jvmMaxHeap = config.jvmMaxHeap ? : jvmMaxHeap,
184
- jvmRuntimeArgs = config.jvmRuntimeArgs + jvmRuntimeArgs,
185
- jvmMainClass = config.jvmMainClass + jvmMainClass,
186
- jvmMainArgs = config.jvmMainArgs + jvmMainArgs,
185
+ jvmRuntimeArgs = merge( config.jvmRuntimeArgs, jvmRuntimeArgs) ,
186
+ jvmMainClass = merge( config.jvmMainClass, jvmMainClass) ,
187
+ jvmMainArgs = merge( config.jvmMainArgs, jvmMainArgs) ,
187
188
)
188
189
}
190
+
191
+ /* * Helper method to combine arrays without duplication */
192
+ private fun merge (base : Array <String >, toMerge : Array <String >): Array <String > {
193
+ return (base + toMerge).distinct().toTypedArray()
194
+ }
189
195
}
190
196
191
197
// NB: Previously, the TOML config reader was implemented simply using ktoml.
@@ -302,7 +308,7 @@ fun readConfig(
302
308
303
309
// Recursively read config file includes.
304
310
for (path in includes ? : emptyList()) {
305
- theConfig + = readConfig(tomlFile.dir / path, theConfig, theVisited)
311
+ theConfig = readConfig(tomlFile.dir / path, theConfig, theVisited)
306
312
}
307
313
308
314
// Return the final result.
0 commit comments