Kapt3: Support 'processors' option in Gradle plugin (KT-8558)

Also warn if kapt3 options are used without the "apply plugin: 'kotlin-kapt'" specified.
This commit is contained in:
Yan Zhulanow
2017-02-21 19:29:26 +03:00
parent 47ab47d6d1
commit 40fa5fb758
8 changed files with 86 additions and 1 deletions
@@ -51,6 +51,14 @@ internal fun Project.initKapt(
val kaptExtension = extensions.getByType(KaptExtension::class.java)
val kotlinAfterJavaTask: KotlinCompile?
fun warnUnsupportedKapt1Option(optionName: String) {
kotlinTask.logger.kotlinWarn("'$optionName' option is not supported by this kapt implementation. " +
"Please add the \"apply plugin: 'kotlin-kapt\" line to your build script to enable it.")
}
if (kaptExtension.processors.isNotEmpty()) warnUnsupportedKapt1Option("processors")
if (kaptExtension.correctErrorTypes) warnUnsupportedKapt1Option("correctErrorTypes")
if (kaptExtension.generateStubs) {
kotlinAfterJavaTask = createKotlinAfterJavaTask(javaTask, kotlinTask, kotlinOptions, tasksProvider)
@@ -173,6 +173,11 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
pluginOptions += SubpluginOption("sources", generatedFilesDir.canonicalPath)
pluginOptions += SubpluginOption("classes", getKaptClasssesDir(project, sourceSetName).canonicalPath)
val annotationProcessors = kaptExtension.processors
if (annotationProcessors.isNotEmpty()) {
pluginOptions += SubpluginOption("processors", annotationProcessors)
}
val androidPlugin = variantData?.let {
project.extensions.findByName("android") as? BaseExtension
}
@@ -30,6 +30,8 @@ open class KaptExtension {
open var correctErrorTypes: Boolean = false
open var processors: String = ""
private var closure: Closure<*>? = null
open fun arguments(closure: Closure<*>) {