Maven plugin that post-processes modular applications' module-info.class
files after compilation to add all the required provides
clauses for all services registered under META-INF/services
as well as adding requires
for certain avaje-inject plugins if applicable.
This plugin uses the JDK 22 Class-File API. As the feature is still in preview, create a .mvn/jvm.config
file and add --enable-preview
so that the maven JVM will run with preview features.
<plugin>
<groupId>io.avaje</groupId>
<artifactId>avaje-provides-maven-plugin</artifactId>
<version>${version}</version>
<extensions>true</extensions>
</plugin>
Given a module-info like:
module avaje.example {
requires io.avaje.inject;
requires io.avaje.jsonb;
requires static io.avaje.spi;
}
And a META-INF/my.example.SPIServiceInterface
file (either manually created or generated by APT):
my.example.SPIServiceInterfaceImpl
This goal will transform the module-info classfile after compilation to look like:
module avaje.example {
requires io.avaje.inject;
requires io.avaje.jsonb;
requires io.avaje.jsonb.plugin;
requires static io.avaje.spi;
provides my.example.SPIServiceInterface with my.example.SPIServiceInterfaceImpl;
}
As the add-module-spi
goal runs after compilation, this goal generates a file before compilation that signals any apt project that uses avaje-prisms's ModuleInfoReader
for service validation to disable provides
module validation.