@@ -354,6 +354,34 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
354
354
args.disableStandardScript = disableStandardScript
355
355
}
356
356
357
+ private fun convertJavacArgumentsListToMap (options : List <String >): Map <String , String > {
358
+ val result = mutableMapOf<String , String >()
359
+ var i = 0
360
+
361
+ while (i < options.size) {
362
+ val option = options[i]
363
+ if (option.startsWith(" -" ) || option.startsWith(" --" )) {
364
+ // Check if the option contains an equal sign
365
+ if (option.contains(" =" )) {
366
+ val (key, value) = option.split(" =" , limit = 2 )
367
+ result[key] = value
368
+ } else {
369
+ // Check if the next element is a value for this option
370
+ val value = if (i + 1 < options.size && ! options[i + 1 ].startsWith(" -" )) {
371
+ i++ // Increment the index to skip the value in the next iteration
372
+ options[i]
373
+ } else {
374
+ " "
375
+ }
376
+ result[option] = value
377
+ }
378
+ }
379
+ i++
380
+ }
381
+
382
+ return result
383
+ }
384
+
357
385
/* * Performs the 1st and 2nd compilation step to generate stubs and run annotation processors */
358
386
private fun stubsAndApt (sourceFiles : List <Path >): ExitCode {
359
387
if (annotationProcessors.isEmpty()) {
@@ -373,14 +401,16 @@ class KotlinCompilation : AbstractKotlinCompilation<K2JVMCompilerArguments>() {
373
401
374
402
it.mode = AptMode .STUBS_AND_APT
375
403
376
- it.flags.apply {
404
+ it.javacOptions.putAll(convertJavacArgumentsListToMap(javacArguments))
405
+
406
+ it.flags.apply {
377
407
addAll(kaptFlags)
378
408
379
409
if (verbose) {
380
410
addAll(KaptFlag .MAP_DIAGNOSTIC_LOCATIONS , KaptFlag .VERBOSE )
381
411
}
382
412
}
383
- }
413
+ }
384
414
385
415
val compilerMessageCollector = PrintingMessageCollector (
386
416
internalMessageStream, MessageRenderer .GRADLE_STYLE , verbose
0 commit comments