Skip to content

Commit 106a18a

Browse files
committed
Migrate to jreleaser
1 parent 3d9fafd commit 106a18a

File tree

5 files changed

+62
-126
lines changed

5 files changed

+62
-126
lines changed

.github/workflows/release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- '*.*.*'
7+
- '*.*.*-SNAPSHOT'
78

89
concurrency:
910
group: java-exaroton-api
@@ -13,29 +14,27 @@ jobs:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v4
16-
- name: Set up JDK 11
17+
- name: Set up Java
1718
uses: actions/setup-java@v4
1819
with:
1920
distribution: temurin
2021
java-version: 11
2122
- name: Setup Gradle
2223
uses: gradle/actions/setup-gradle@v4
23-
- name: Build with Gradle
24-
run: ./gradlew build -Prelease=${{ github.ref_name }} --info
25-
env:
26-
EXAROTON_API_TOKEN: ${{ secrets.EXAROTON_API_KEY }}
27-
EXAROTON_TEST_SERVER: "WgvSsfR8ZizUO1RQ"
28-
EXAROTON_TEST_POOL: "N2t9gWOMpzRL37FI"
2924
- name: Publish to Maven Central
3025
env:
31-
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.EXAROTON_GPG_SIGNING_KEY }}
32-
ORG_GRADLE_PROJECT_SIGNING_PASSPHRASE: ${{ secrets.EXAROTON_GPG_SIGNING_PASSPHRASE }}
33-
ORG_GRADLE_PROJECT_OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
34-
ORG_GRADLE_PROJECT_OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
26+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.EXAROTON_GPG_SIGNING_KEY }}
27+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.EXAROTON_GPG_SIGNING_PUBLIC_KEY }}
28+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.EXAROTON_GPG_SIGNING_PASSPHRASE }}
29+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
JRELEASER_NEXUS2_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
31+
JRELEASER_NEXUS2_TOKEN: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
32+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
33+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
3534
EXAROTON_API_TOKEN: ${{ secrets.EXAROTON_API_KEY }}
3635
EXAROTON_TEST_SERVER: "WgvSsfR8ZizUO1RQ"
3736
EXAROTON_TEST_POOL: "N2t9gWOMpzRL37FI"
38-
run: ./gradlew publish -Prelease=${{ github.ref_name }}
37+
run: ./gradlew clean publish jreleaserDeploy -Prelease=${{ github.ref_name }}
3938
- name: Create Release
4039
uses: softprops/action-gh-release@v1
4140
with:

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ concurrency:
1212
jobs:
1313
test:
1414
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
java: [11, 17, 21]
1518
steps:
1619
- uses: actions/checkout@v4
1720
- name: Set up Java
1821
uses: actions/setup-java@v4
1922
with:
2023
distribution: temurin
21-
java-version: 11
24+
java-version: ${{ matrix.java }}
2225
- name: Setup Gradle
2326
uses: gradle/actions/setup-gradle@v4
2427
- name: Build with Gradle

CHANGELOG.md

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,2 @@
1-
# 2.2.1
2-
## Added
3-
- `CreditPool#getClient()`
4-
5-
## Fixed
6-
- Objects returned by `ExarotonClient#getServers` and `ExarotonClient#getCreditPools` are now correctly initialized
7-
8-
# 2.2.0
9-
10-
## Added
11-
- `Server#getSocketAddress()` which returns an `InetSocketAddress` of the server's IP and port if the server is online
12-
13-
# 2.1.0
14-
15-
## Added
16-
- `ServerConfig#setOptions(Collection<ConfigOption<?>>)`
17-
- `ServerConfig#setOptions(Map<String, ConfigOption<?>>)`
18-
19-
# 2.0.0
20-
21-
## Breaking Changes
22-
## Java 11
23-
This library now requires Java 11 or higher.
24-
25-
## Async API
26-
All methods that make requests to the Exaroton API are now asynchronous. This means that all methods that return a value
27-
now return a `CompletableFuture` instead. To get the result of the request you can use `CompletableFuture#get()` or
28-
`CompletableFuture#join()`.
29-
30-
This also changes where exceptions are thrown. Now the following rules apply:
31-
- IOExceptions are thrown directly by the API methods
32-
- APIExceptions cause the CompletableFuture to complete exceptionally
33-
34-
If you use `join()` or `get()` a `CompletionException` containing the `APIException` will be thrown.
35-
36-
## Fetch methods
37-
Many objects can be obtained from the API client without fetching their data (e.g. Server, CreditPool, ServerFile, ...).
38-
The method to fetch their data has been renamed from `get` to `fetch`. It now also offers an override with a boolean
39-
parameter that can be used to only fetch the object once `server.fetch(false)`.
40-
41-
## ServerStatus
42-
The `ServerStatus` class is now an enum instead of a class with static `int` fields. Each status has a numeric
43-
value (`getValue`), a display name (`getName`) and a brand color (`getColor`).
44-
45-
If a status code is unknown because the API client has not been updated `OFFLINE` will be returned.
46-
47-
### SLF4J Implementation
48-
This library no longer depends directly on any SLF4J implementation. If you want to see log messages
49-
from this library, you must include an SLF4J implementation in your project.
50-
51-
### API Requests
52-
53-
#### Request Bodies
54-
`ApiRequest#getBody()` and `ApiRequest#getInputStream()` have been replaced by `ApiRequest#getBodyPublisher()`. For a
55-
JSON body you can use `ApiRequest#jsonBodyPublisher(Object)`. This only affects users who extended the request classes.
56-
57-
`PutFileDataRequest`'s constructor has been changed to accept a `Supplier<InputStream>` instead of an `InputStream`.
58-
59-
#### Request Methods
60-
`ApiRequest#requestRaw()`, `ApiRequest#requestString()` and `ApiRequest#request()` have been replaced by
61-
`ExarotonClient#request(ApiRequest, HttpResponse.BodyHandler)` use the respective body handlers to get an input stream,
62-
string or object.
63-
64-
### WebSockets
65-
The `java-websocket` library has been replaced by the built-in Java 11 websocket implementation. Websocket connections
66-
are now automatically created when a subscriber is registered and closed when the last subscriber is removed. Manually
67-
closing a connection using `Server#unsubscribe()` is still supported. This method does not throw an exception if there
68-
is no connection to close.
69-
70-
The debug/error handler methods have been removed. Errors and debug messages are now exclusively logged using SLF4J
71-
72-
#### Subscribers
73-
The `Subscriber` classes are now interfaces and their methods have been renamed to make the more explicit and reduce
74-
the chance of conflicts with other overrides.
75-
76-
### Other
77-
- Arrays have been Replaced by Collection's in almost all places
78-
- Nullable return types have been replaced by Optional's
79-
- Public final properties have been replaced by getters
80-
- Config options now return a generic type instead of `Object`
81-
- Renamed `ServerFile#getInfo` to `ServerFile#get`
82-
- Removed `ExarotonClient#getGson()` and `WebsocketClient#getGson()`
83-
- Removed `Server#setClient` and `CreditPool#setClient`
84-
- Removed `ExarotonClient#getBaseUrl()` and `ExarotonClient#createConnection(String, String)`
85-
- Many classes are now final
86-
- Added `ApiStatus` annotations to many classes and methods
87-
- Removed `ExarotonClient#getApiToken()`
88-
- `ExarotonClient#setProtocol` and `ExarotonClient#getProtocol` have been removed as HTTP is not supported by the API
89-
90-
## Improvements
91-
- Update dependencies
92-
- Make jetbrains annotations compile only
1+
## Build System
2+
- Migrate to new Maven Central publishing system.

build.gradle

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4-
id 'signing'
4+
alias(libs.plugins.jreleaser)
55
}
66

77
sourceCompatibility = JavaVersion.VERSION_11
@@ -49,18 +49,6 @@ java {
4949
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
5050

5151
publishing {
52-
repositories {
53-
maven {
54-
def releaseRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
55-
def snapshotRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
56-
url = isReleaseVersion ? releaseRepo : snapshotRepo
57-
credentials {
58-
username = findProperty('OSSRH_USERNAME')
59-
password = findProperty('OSSRH_PASSWORD')
60-
}
61-
}
62-
}
63-
6452
publications {
6553
mavenJava(MavenPublication) {
6654
artifactId = 'api'
@@ -90,16 +78,47 @@ publishing {
9078
}
9179
}
9280
}
93-
}
9481

95-
signing {
96-
def signingKey = findProperty("SIGNING_KEY").toString()
97-
def signingPassword = findProperty("SIGNING_PASSPHRASE").toString()
98-
useInMemoryPgpKeys(signingKey, signingPassword)
99-
sign publishing.publications.mavenJava
82+
repositories {
83+
maven {
84+
url = layout.buildDirectory.dir('staging-deploy')
85+
}
86+
}
10087
}
101-
tasks.withType(Sign).configureEach {
102-
onlyIf { isReleaseVersion }
88+
89+
jreleaser {
90+
signing {
91+
active = 'RELEASE'
92+
armored = true
93+
}
94+
deploy {
95+
maven {
96+
mavenCentral {
97+
'release-deploy' {
98+
active = 'RELEASE'
99+
url = 'https://central.sonatype.com/api/v1/publisher'
100+
stagingRepository('build/staging-deploy')
101+
}
102+
}
103+
nexus2 {
104+
'snapshot-deploy' {
105+
active = 'SNAPSHOT'
106+
url = 'https://central.sonatype.com/api/v1/publisher'
107+
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots'
108+
snapshotSupported = true
109+
closeRepository = true
110+
releaseRepository = true
111+
stagingRepository('build/staging-deploy')
112+
}
113+
}
114+
}
115+
}
116+
117+
release {
118+
github {
119+
skipRelease = true
120+
}
121+
}
103122
}
104123

105124
jar {

gradle/libs.versions.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ jetbrains-annotations = "26.0.2"
44
slf4j = "2.0.17"
55
# Test dependencies
66
junit = "5.12.0"
7+
# Plugins
8+
jreleaser = "1.18.0"
79

810
[libraries]
911
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
@@ -13,3 +15,6 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
1315
junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
1416
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
1517
slf4j-jdk14 = { module = "org.slf4j:slf4j-jdk14", version.ref = "slf4j" }
18+
19+
[plugins]
20+
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" }

0 commit comments

Comments
 (0)