小编She*_*ard的帖子

Kotlin 注释处理器:无法让它工作

我的gradle构建:

buildscript {
    ext.kotlin_version = '1.1.4-3'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: "kotlin-kapt"

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


kapt {
    processors = "libs.orm.codeGenerators.ModelProcessor" //PROCESSOR
}


dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

    compile "com.google.auto.service:auto-service:1.0-rc3"   
}
Run Code Online (Sandbox Code Playgroud)

处理器不在单独的模块中。

处理器什么都不做,#process只是简单地抛出,看看它是否工作。

@AutoService(Processor::class)
@SupportedSourceVersion(SourceVersion.RELEASE_8)
class ModelProcessor : AbstractProcessor() {

    override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment): Boolean {
        throw(Throwable("foo"))
        return true
    }

    override fun getSupportedAnnotationTypes() : MutableSet<String> {
        return mutableSetOf<String>("*")
    }

} …
Run Code Online (Sandbox Code Playgroud)

kotlin kapt

3
推荐指数
1
解决办法
1330
查看次数

标签 统计

kapt ×1

kotlin ×1