Kapt3: Use 'compilerArgs' safely (KT-16990)
'android-apt' (com.neenbedankt) adds the 'File' instance to 'compilerArgs' (List<String>).
This commit is contained in:
+9
-1
@@ -262,7 +262,15 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
|||||||
private fun Kapt3SubpluginContext.disableAnnotationProcessingInJavaTask() {
|
private fun Kapt3SubpluginContext.disableAnnotationProcessingInJavaTask() {
|
||||||
(javaCompile as? JavaCompile)?.let { javaCompile ->
|
(javaCompile as? JavaCompile)?.let { javaCompile ->
|
||||||
val options = javaCompile.options
|
val options = javaCompile.options
|
||||||
options.compilerArgs = options.compilerArgs.filter { !it.startsWith("-proc:") } + "-proc:none"
|
// 'android-apt' (com.neenbedankt) adds a File instance to compilerArgs (List<String>).
|
||||||
|
// Although it's not our problem, we need to handle this case properly.
|
||||||
|
val oldCompilerArgs: List<Any> = options.compilerArgs
|
||||||
|
val newCompilerArgs = oldCompilerArgs.filterTo(mutableListOf()) {
|
||||||
|
it !is CharSequence || !it.toString().startsWith("-proc:")
|
||||||
|
}
|
||||||
|
newCompilerArgs.add("-proc:none")
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
options.compilerArgs = newCompilerArgs as List<String>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user