@@ -111,6 +111,35 @@ internal fun JvmCompilationTask.preProcessingSteps(
111
111
return context.execute(" expand sources" ) { expandWithSourceJarSources() }
112
112
}
113
113
114
+ internal fun parseJavacArgsToMap (args : List <String >): Map <String , String > {
115
+ val optionsMap = mutableMapOf<String , String >()
116
+ var i = 0
117
+
118
+ while (i < args.size) {
119
+ val arg = args[i]
120
+
121
+ // map option arguments as key value pairs e.g. --source 8 => ("--source", "8")
122
+ // map flag arguments as key with value = "true" e.g. map -nowarn => ("-nowarn", "true")
123
+ if (arg.startsWith(" -" )) {
124
+ val hasNext = i + 1 < args.size
125
+ val nextArg = if (hasNext) args[i + 1 ] else null
126
+
127
+ if (hasNext && ! nextArg!! .startsWith(" -" )) {
128
+ optionsMap[arg] = nextArg
129
+ i + = 2
130
+ } else {
131
+ optionsMap[arg] = " true"
132
+ i++
133
+ }
134
+ } else {
135
+ // Ignore non-option arguments
136
+ i++
137
+ }
138
+ }
139
+
140
+ return optionsMap
141
+ }
142
+
114
143
internal fun encodeMap (options : Map <String , String >): String {
115
144
val os = ByteArrayOutputStream ()
116
145
val oos = ObjectOutputStream (os)
@@ -131,10 +160,15 @@ internal fun JvmCompilationTask.kaptArgs(
131
160
plugins : InternalCompilerPlugins ,
132
161
aptMode : String ,
133
162
): CompilationArgs {
134
- val javacArgs = mapOf<String , String >(
135
- " -target" to info.toolchainInfo.jvm.jvmTarget,
136
- " -source" to info.toolchainInfo.jvm.jvmTarget,
163
+ val javacArgs = parseJavacArgsToMap(
164
+ listOf (
165
+ " -target" ,
166
+ info.toolchainInfo.jvm.jvmTarget,
167
+ " -source" ,
168
+ info.toolchainInfo.jvm.jvmTarget,
169
+ ).plus(inputs.javacFlagsList),
137
170
)
171
+
138
172
return CompilationArgs ().apply {
139
173
xFlag(" plugin" , plugins.kapt.jarPath)
140
174
0 commit comments