File tree 1 file changed +30
-0
lines changed
core/src/main/kotlin/com/tschuchort/compiletesting
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,34 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
350
350
args.suppressMissingBuiltinsError = suppressMissingBuiltinsError
351
351
}
352
352
353
+ private fun convertJavacArgumentsListToMap (options : List <String >): Map <String , String > {
354
+ val result = mutableMapOf<String , String >()
355
+ var i = 0
356
+
357
+ while (i < options.size) {
358
+ val option = options[i]
359
+ if (option.startsWith(" -" ) || option.startsWith(" --" )) {
360
+ // Check if the option contains an equal sign
361
+ if (option.contains(" =" )) {
362
+ val (key, value) = option.split(" =" , limit = 2 )
363
+ result[key] = value
364
+ } else {
365
+ // Check if the next element is a value for this option
366
+ val value = if (i + 1 < options.size && ! options[i + 1 ].startsWith(" -" )) {
367
+ i++ // Increment the index to skip the value in the next iteration
368
+ options[i]
369
+ } else {
370
+ " "
371
+ }
372
+ result[option] = value
373
+ }
374
+ }
375
+ i++
376
+ }
377
+
378
+ return result
379
+ }
380
+
353
381
/* * Performs the 1st and 2nd compilation step to generate stubs and run annotation processors */
354
382
private fun stubsAndApt (sourceFiles : List <Path >): ExitCode {
355
383
if (annotationProcessors.isEmpty()) {
@@ -369,6 +397,8 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
369
397
370
398
it.mode = AptMode .STUBS_AND_APT
371
399
400
+ it.javacOptions.putAll(convertJavacArgumentsListToMap(javacArguments))
401
+
372
402
if (verbose)
373
403
it.flags.addAll(KaptFlag .MAP_DIAGNOSTIC_LOCATIONS , KaptFlag .VERBOSE )
374
404
}
You can’t perform that action at this time.
0 commit comments