From 2a027b6d09a7ca77019e3213a43fa648c1da3df6 Mon Sep 17 00:00:00 2001 From: Josiah Noel <32279667+SentryMan@users.noreply.github.com> Date: Sun, 15 Dec 2024 23:21:48 -0500 Subject: [PATCH] use JDK 24 --- .github/workflows/jdk-ea.yml | 2 +- README.md | 17 ++++++----------- pom.xml | 2 +- .../mojo/DisableModuleValidationMojo.java | 2 +- .../io/avaje/inject/mojo/ModuleSPIMojo.java | 12 +++--------- .../resources/META-INF/plexus/components.xml | 5 +---- 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/.github/workflows/jdk-ea.yml b/.github/workflows/jdk-ea.yml index c09928f..2889f29 100644 --- a/.github/workflows/jdk-ea.yml +++ b/.github/workflows/jdk-ea.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: [GA,EA] ## valhalla,metropolis don't support java 17 + java_version: [GA,EA] os: [ubuntu-latest] steps: diff --git a/README.md b/README.md index 27bf0d3..e6316b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Supported JVM Versions](https://img.shields.io/badge/JVM-23-brightgreen.svg?&logo=openjdk) +![Supported JVM Versions](https://img.shields.io/badge/JVM-24-brightgreen.svg?&logo=openjdk) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/avaje/avaje-inject/blob/master/LICENSE) ![Maven Central : avaje-provides-maven-plugin](https://img.shields.io/maven-central/v/io.avaje/avaje-provides-maven-plugin.svg?label=Maven%20Central) @@ -8,10 +8,7 @@ Maven plugin that post-processes modular applications' `module-info.class` files ## How to use -### 1. Create a `.mvn/jvm.config` file -This plugin uses the JDK 22 [Class-File API](https://openjdk.org/jeps/457). 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 +### 1. Add the plugin to your pom.xml ```xml @@ -31,25 +28,23 @@ Given a module-info like: ```java 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): +And a `META-INF/services/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: + +This goal will transform the module-info classfile after compilation to roughly look like: ```java 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; @@ -58,4 +53,4 @@ module avaje.example { ### `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. +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. \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3a0dc5b..c8a4aa1 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ maven-plugin 1.2-SNAPSHOT - 23 + 24 diff --git a/src/main/java/io/avaje/inject/mojo/DisableModuleValidationMojo.java b/src/main/java/io/avaje/inject/mojo/DisableModuleValidationMojo.java index 0208971..5f89537 100644 --- a/src/main/java/io/avaje/inject/mojo/DisableModuleValidationMojo.java +++ b/src/main/java/io/avaje/inject/mojo/DisableModuleValidationMojo.java @@ -30,7 +30,7 @@ public class DisableModuleValidationMojo extends AbstractMojo { public void execute() throws MojoExecutionException { if (Integer.getInteger("java.specification.version") < 24) { - getLog().warn("This version of the avaje-provides-plugin only works on JDK 24 and up"); + getLog().error("This version of the avaje-provides-plugin only works on JDK 24 and up"); return; } diff --git a/src/main/java/io/avaje/inject/mojo/ModuleSPIMojo.java b/src/main/java/io/avaje/inject/mojo/ModuleSPIMojo.java index 452beea..6a2ce55 100644 --- a/src/main/java/io/avaje/inject/mojo/ModuleSPIMojo.java +++ b/src/main/java/io/avaje/inject/mojo/ModuleSPIMojo.java @@ -1,10 +1,8 @@ package io.avaje.inject.mojo; import java.io.File; -import java.lang.management.ManagementFactory; import java.nio.file.Files; import java.util.HashSet; -import java.util.List; import java.util.Set; import org.apache.maven.plugin.AbstractMojo; @@ -24,15 +22,11 @@ public class ModuleSPIMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException { - var canRun = - Integer.getInteger("java.specification.version") == 23 - && ManagementFactory.getRuntimeMXBean().getInputArguments().stream() - .anyMatch("--enable-preview"::equals); - if (!canRun) { + if (Integer.getInteger("java.specification.version") < 24) { getLog() - .warn( - "This version of the avaje-provides-plugin only works on JDK 23 with --enable-preview cofigured in MAVEN_OPTS"); + .error( + "This version of the avaje-provides-plugin only works on JDK 24 and up"); return; } diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml index ff851aa..15c16da 100644 --- a/src/main/resources/META-INF/plexus/components.xml +++ b/src/main/resources/META-INF/plexus/components.xml @@ -4,7 +4,7 @@ org.apache.maven.lifecycle.Lifecycle org.apache.maven.lifecycle.Lifecycle - avaje-inject-maven-plugin + avaje-provides-maven-plugin avaje-provides-maven-plugin @@ -14,9 +14,6 @@ io.avaje:avaje-provides-maven-plugin:${project.version}:disable-apt-validation - - io.avaje:avaje-inject-maven-plugin:10.4:provides - io.avaje:avaje-provides-maven-plugin:${project.version}:add-module-spi