avaje / avaje-provides-plugin

module-info transformation via the classfile API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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>

Example module-info.class transformation

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

The module-info classfile will be transformed 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;
}

About

module-info transformation via the classfile API


Languages

Language:Java 100.0%