Skip to content

Commit

Permalink
feat: support Maven 4.0
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Sep 23, 2024
1 parent 66492e4 commit 3cb25e9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -47,7 +47,7 @@ subprojects {
trimTrailingWhitespace()
}
java {
palantirJavaFormat("2.36.0")
palantirJavaFormat("2.50.0")
importOrder("\\#|")
removeUnusedImports()
endWithNewline()
Expand Down
8 changes: 8 additions & 0 deletions dev/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# How to release OS Detector

```shell
./gradlew publishToMavenLocal
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
./gradlew publishPlugins --validate-only
./gradlew publishPlugins
```
9 changes: 5 additions & 4 deletions plugin-maven/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,12 +37,13 @@ tasks.withType<GenerateHelpMojoSourcesTask>().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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3cb25e9

Please sign in to comment.