plugins {
id 'kotlin-kapt'
}
dependencies {
kapt 'com.example:my-annotation-processor:1.0.0'
}
kapt {
correctErrorTypes = true
arguments {
arg("my-argument", "value")
}
}
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class MyAnnotation(val value: String)
@AutoService(Processor::class)
class MyAnnotationProcessor : AbstractProcessor() {
override fun getSupportedAnnotationTypes(): MutableSet<String> {
return mutableSetOf(MyAnnotation::class.java.name)
}
override fun process(
annotations: MutableSet<out TypeElement>?,
roundEnv: RoundEnvironment?
): Boolean {
val elements = roundEnv?.getElementsAnnotatedWith(MyAnnotation::class.java)
return true
}
}