Project as annotationProcessor not working properly

I am working on a annotation processor project with multi-module Gradle Build Setup. The annotation processor itself is written as a sub-module (say processor). A test module (say example) has annotationProcessor dependency on the processor module.

I have recreated a sample project to showcase the issue I am facing.

The annotation processor module uses ServiceLoader in its implementation. When I build the project using gradle :example:build, the ServiceLoader can’t discover its implementation of the service provided which causes issue in my code flow.

Project build

This issue is not occurring when I build the classes directly in Intellij IDEA.

Need help in resolving this issue.

Are you sure you included the correct sample project? I don’t have any issues building the one in the repository provided.

I gave reference to a wrong project. I have edited the question to point to the correct repo

Any help on this would be very much appreciated