0

I have written a custom annotation processor and configured with maven compiler plugin as shown below, I am facing issue with Immutables annotation processor which is in my application class path. When I add my annotation processor via maven compiler plugin, the Immutables is giving compilation errors. I need Immutables as well in my project.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
        <annotationProcessors>
            <annotationProcessor>
                org.smarttechie.TraceAnnotationProcessor
            </annotationProcessor>
        </annotationProcessors>
    </configuration>
</plugin>

Any hints to use Immutables/any annotation processors along with my custom annotation processor.

SmartTechie
  • 135
  • 2
  • 10

1 Answers1

1

Package your annotation processor into a JAR and include that JAR as a compilation dependency. Be sure to add META-INF/services/javax.annotation.processing.Processor to your JAR (contents single line with your processor class name):

org.smarttechie.TraceAnnotationProcessor

If you don't want your new JAR included as a dependency of your generated artifact, mark it prodided and/or true.

Allen D. Ball
  • 1,916
  • 1
  • 9
  • 16
  • Some how when I add the jar which has the custom annotation processor, during the compile time the annotation processor is not invoked the way it was when I add it though maven plugin. The dependency scope is compile only. – SmartTechie Oct 11 '21 at 21:14
  • My apologies, I neglected a step. I have updated my answer. – Allen D. Ball Oct 12 '21 at 02:28