has someone a good tip for a kapt tutorial for ser...
# announcements
s
has someone a good tip for a kapt tutorial for serverside annotation processing? (Android is not involved in any way. The task is to generate a documentation file containing which classes contain certain annotations. Since it's Kotlin files we're talking about, I guess that kapt is the right tool for the job!?)
b
There's also #C013BA8EQSE I'd expect there being markdown docs in the repos
Otherwise just look at existing examples on github
s
ok, I looked into KSP a bit, but since it's an alpha release it's too early for me to use it (,since I'm not working on a private project, but for my employer).
👍 1
e
every annotation processor example out there should have something like
Copy code
class MyProcessor : AbstractProcessor() {
    override fun process(annotations: Set<out TypeElement>, roundEnv: RoundEnvironment): Boolean {
        val elements = roundEnv.getElementsAnnotatedWith(MyAnnotation::class.java)
        // do something with each element
        return true
    }
}
you can use the filer to write to a resource
w
s
@Wayne Yang but that's an Android project, so I'm not sure if there are android specific parts. What is this
auto-service
component that kapt is called to consume(?)
kapt "com.google.auto.service:auto-service:1.0-rc4"
? I'm aiming for pure serverside.
@ephemient The class is pretty straight forward, but I'm more confused by the configuration.
e
autoservice writes a resource for you. in fact, you should look at its source code as your goal seems similar
👍 1
annotation processing configuration is easy, just a resource file or a few (which autoservice can help with as well)
the only thing that isn't documented on Java's side is the Gradle integration, which of course makes sense as it's Gradle-specific, but... read it to keep your builds fast and correct https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing
👍 1