Hi Team,
I am working on a project where I have to migrate from Maven to Gradle (version 7.6). There are some dependencies (jars) which have annotationProcessors declared within them. These annotationProcessors generate some code whenever a new build is created.
These code do not get generated when I create a build with gradle wrapper using the following.
./gradlew clean build
Strangely when I try to build the project using maven using the command
mvn clean build
these annotation processors are executed and I can see the code generated.
Following is a code snippet of the pom file of the jar (let’s call it foo.jar) for the annotation-processor:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>foo</groupId>
<artifactId>foo-annotation-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>foo.annotationprocessor.class1</annotationProcessor>
<annotationProcessor>foo.annotationprocessor.class2</annotationProcessor>
</annotationProcessors>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>
The annotation processor class uses the Google AutoService annotation (@AutoService).
The aforementioned jar is imported as a dependency in the pom.xml.
I have tried to follow the same in the build.gradle with the following dependecies:
implementation("com.google.auto.service:auto-service-annotations:1.0.1")
annotationProcessor("com.google.auto.service:auto-service:1.0.1")
implementation("foo.jar")
annotationProcessor("foo.jar")
But for some reason the annotation processors do not get executed. Can someone please help me with this issue? I am not sure what I am missing here.