From 3cb25e93d8c969c83d3aef933adf749a8f92a2dd Mon Sep 17 00:00:00 2001 From: tison Date: Mon, 23 Sep 2024 16:57:49 +0800 Subject: [PATCH] feat: support Maven 4.0 Signed-off-by: tison --- .github/workflows/ci.yml | 2 +- README.md | 8 +++++--- build.gradle.kts | 4 ++-- dev/RELEASE.md | 8 ++++++++ plugin-maven/build.gradle.kts | 9 +++++---- .../main/java/com/tisonkun/os/maven/DetectExtension.java | 5 +++++ .../src/main/java/com/tisonkun/os/maven/DetectMojo.java | 5 +++++ 7 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 dev/RELEASE.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f19847..2f021ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Check license header - uses: korandoru/hawkeye@v4 + uses: korandoru/hawkeye@v5 - name: Setup Java uses: actions/setup-java@v4 with: diff --git a/README.md b/README.md index f611a00..19551be 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # OS Detector -A detector for the OS name and architecture, providing a uniform classifier to be used in the names of native artifacts. +![Maven Central](https://img.shields.io/maven-central/v/com.tisonkun.os/os-detector-core.svg?logo=Apache+Maven&logoColor=blue) -This repository is an effort to provide the OS detection logic the same as [os-maven-plugin](https://github.com/trustin/os-maven-plugin/) as a standalone artifact, and redistribute the Maven plugin as well as [the Gradle plugin](https://github.com/google/osdetector-gradle-plugin) (developed by Google) based on such a core lib to align the manner. +A detector for the OS name and architecture. It provides a uniform classifier to be used in the names of native artifacts. + +This repository is an effort to provide functionalities the same as [os-maven-plugin](https://github.com/trustin/os-maven-plugin/), but as a standalone artifact. It also redistributes the Maven plugin as well as [the Gradle plugin](https://github.com/google/osdetector-gradle-plugin) (developed by Google) based on such a core lib to ensure the manner is the same. I'm seeking for merging these three efforts into one. Check [this issue](https://github.com/trustin/os-maven-plugin/issues/70#issuecomment-1906110062) for more information. -Currently, I'm actively maintaining this repository (lib, plugin-maven and plugin-gradle) for publicly testing, as well as bugfixes + improvements. You can use it as a production-ready solution since the original logics are battle-tested over the years. +Currently, I'm actively maintaining this repository (`lib`, `plugin-maven` and `plugin-gradle`) for publicly testing, as well as bugfixes + improvements. You can use it as a production-ready solution since the original logics are battle-tested over the years. ## Programmable diff --git a/build.gradle.kts b/build.gradle.kts index d25a250..7d3debf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { - id("com.diffplug.spotless") version "6.24.0" + id("com.diffplug.spotless") version "6.25.0" id("io.github.gradle-nexus.publish-plugin") version "1.3.0" id("java") } @@ -47,7 +47,7 @@ subprojects { trimTrailingWhitespace() } java { - palantirJavaFormat("2.36.0") + palantirJavaFormat("2.50.0") importOrder("\\#|") removeUnusedImports() endWithNewline() diff --git a/dev/RELEASE.md b/dev/RELEASE.md new file mode 100644 index 0000000..11c96f7 --- /dev/null +++ b/dev/RELEASE.md @@ -0,0 +1,8 @@ +# How to release OS Detector + +```shell +./gradlew publishToMavenLocal +./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository +./gradlew publishPlugins --validate-only +./gradlew publishPlugins +``` diff --git a/plugin-maven/build.gradle.kts b/plugin-maven/build.gradle.kts index b4183e2..bc7f5ca 100644 --- a/plugin-maven/build.gradle.kts +++ b/plugin-maven/build.gradle.kts @@ -20,7 +20,7 @@ import de.benediktritter.maven.plugin.development.task.GenerateMavenPluginDescri plugins { id("java-publish") // @see https://www.benediktritter.de/maven-plugin-development/ - id("de.benediktritter.maven-plugin-development") version "0.4.2" + id("de.benediktritter.maven-plugin-development") version "0.4.3" } mavenPlugin { @@ -37,12 +37,13 @@ tasks.withType().configureEach { } dependencies { - compileOnly("org.apache.maven:maven-plugin-api:3.9.6") + compileOnly("org.apache.maven:maven-api-spi:4.0.0-alpha-13") + compileOnly("org.apache.maven:maven-plugin-api:3.9.9") compileOnly("org.apache.maven.plugin-tools:maven-plugin-annotations:3.11.0") - implementation("org.apache.maven:maven-core:3.9.6") + implementation("org.apache.maven:maven-core:3.9.9") implementation("org.codehaus.plexus:plexus-utils:4.0.0") implementation(project(":lib")) - testImplementation("org.apache.maven.shared:maven-invoker:3.2.0") + testImplementation("org.apache.maven.shared:maven-invoker:3.3.0") } tasks.test { diff --git a/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectExtension.java b/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectExtension.java index 1ceead3..8f40595 100644 --- a/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectExtension.java +++ b/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectExtension.java @@ -73,6 +73,11 @@ public class DetectExtension extends AbstractMavenLifecycleParticipant { private final Logger logger; private final Detector detector; + /** + * Create a Maven extension instance with the platform specific logger. + * + * @param logger the platform specific logger + */ @Inject public DetectExtension(final Logger logger) { this.logger = logger; diff --git a/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectMojo.java b/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectMojo.java index f32b1a1..486e10e 100644 --- a/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectMojo.java +++ b/plugin-maven/src/main/java/com/tisonkun/os/maven/DetectMojo.java @@ -65,6 +65,11 @@ public class DetectMojo extends AbstractMojo { private final Detector detector = new Detector( new DefaultSystemPropertyOperations(), new DefaultFileOperations(), message -> getLog().info(message)); + /** + * Create a mojo instance to detect OS information. + */ + public DetectMojo() {} + @Override public void execute() throws MojoExecutionException { try {