Kotlin 注解处理
Follow these steps:
Apply the
kotlin-kaptGradle plugin:KotlinGroovy
plugins { kotlin("kapt") version "1.8.0" }Add the respective dependencies using the
kaptconfiguration in yourdependenciesblock:KotlinGroovy
dependencies { kapt("groupId:artifactId:version") }If you previously used the Android support for annotation processors, replace usages of the
annotationProcessorconfiguration withkapt. If your project contains Java classes,kaptwill also take care of them.If you use annotation processors for your
androidTestortestsources, the respectivekaptconfigurations are namedkaptAndroidTestandkaptTest. Note thatkaptAndroidTestandkaptTestextendskapt, so you can just provide thekaptdependency and it will be available both for production sources and tests.To use the newest Kotlin features with kapt, for example, repeatable annotations, enable the support for the IR backend with the following option in your
gradle.properties:kapt.use.jvm.ir=true
Last updated