Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 2.06 KB

README.md

File metadata and controls

61 lines (43 loc) · 2.06 KB

Supported JVM Versions License Maven Central : avaje-provides-maven-plugin

Avaje Provides Maven Plugin

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.

How to use

1. Create a .mvn/jvm.config file

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.

2. Add the plugin to your pom.xml

<plugin>
  <groupId>io.avaje</groupId>
  <artifactId>avaje-provides-maven-plugin</artifactId>
  <version>${version}</version> 
  <extensions>true</extensions>
</plugin>

Goals

add-module-spi

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;
}

disable-apt-validation

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.