I am building a Java 11 application with Maven.
I have a modularized annotation processor as a dependency and I want it to be discovered and run by javac, but I cannot make it work as expected. (Or maybe my expectations are wrong?)
I have provides Processor with ...
in my module-info
file, and don't have any files in META-INF/services
in processor jar, that is new way ServiceLoader
works, right? This processor jar is passed to javac in --module-path
property, but no processors were executed.
I tried specifying this dependency in <annotationProcessorPaths>
for compiler plugin, but it uses -processorpath
propery, which is an old way! This dependency doesn't have META-INF/services
, so no processors were detected and run.
When I manually specified this in <compilerArgs>
:
--processor-module-path=${settings.localRepository}/<path_to_my_jar>
...then processor was found and executed!
So, javac has a "default annotation processor discovery process" and here is an old answer about it: What is the default annotation processors discovery process?
But this discovery process isn't working for me since Java 9.
Despite my processor jar is in modulepath, no processors gets found until I manually specify processor jar with --processor-module-path
.
So there are 2 problems:
- Javac doesn't find an annotation processor in modulepath
- Maven compiler plugin doesn't have any way to specify modularized annotation processors except raw
<compilerArgs>
Am I missing something?