Custom annotation processor .process() not being invoked

627 Views Asked by At

I'm trying to make a custom annotation processor and it's not being invoked. It IS being .init though, but it never seems to call .process. Any help would be greatly appreciated!

Versions:

  • Kotlin(1.3.72)
  • JRE(11.0.7)
  • Maven(3.8.0)

This is my output from the console:

[INFO] --- maven-compiler-plugin:3.8.0:compile (java-compile) @ mesh ---
[INFO] Changes detected - recompiling the module!
Processor is being init!!
Processor is done init!!

Annotation:

package my.path.annotations

@Target(AnnotationTarget.CLASS)
annotation class MyAnnotation()

AnnotationProcessor:

package my.path.annotations

import <...>

@SupportedAnnotationTypes("my.path.annotations.MyAnnotation")
class MyAnnotationProcessor : AbstractProcessor() {
    private var elementUtils: Elements? = null
    private var messager: Messager? = null

    @Synchronized
    override fun init(env: ProcessingEnvironment?) {
        println("Processor is being init!!")
        super.init(env);
        elementUtils = env!!.elementUtils;
        messager = env.messager;
        println("Processor is done init!!")
    }

    override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment): Boolean {
        println("Processor is being run!!!")
        return true
    }

    override fun getSupportedSourceVersion(): SourceVersion? = SourceVersion.latestSupported()
}

Snippet from pom.xml

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <annotationProcessors>
                        <annotationProcessor> my.path.annotations.MyAnnotationProcessor</annotationProcessor>
                    </annotationProcessors>
                </configuration>

META-INF/services/javax.annotation.processing.Processor file:

my.path.annotations.MyAnnotationProcessor

Used on a class:

@MyAnnotation
class SomeClass @Inject constructor(private val objectMapper: ObjectMapper) {
0

There are 0 best solutions below