Skip to content

Commit dd50e4f

Browse files
authored
Update to support Java 21 (#36)
* Update to support Java 21 * Upgrade gradle to 8.14 * Fix running under Java 21 * fix actions * fix gradle installation
1 parent a325b6b commit dd50e4f

26 files changed

+739
-385
lines changed

.github/workflows/build-main.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,41 @@ jobs:
1515
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
1616
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
1717
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
18-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1918
steps:
20-
- name: Setup JDK 8
21-
uses: actions/setup-java@v3
19+
- name: Setup JDK
20+
uses: actions/setup-java@v4
2221
with:
23-
java-version: '8'
24-
distribution: 'adopt'
22+
java-version: '21'
23+
distribution: 'temurin'
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
with:
27+
gradle-version: '8.14' # Quotes required to prevent YAML converting to number
28+
- name: Setup GO
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: stable
2532
- name: Install Nats Server
2633
run: |
27-
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
28-
sudo mv nats-server /usr/local/bin
34+
pkill -9 nats-server 2>/dev/null || true
35+
mkdir -p ~/.local/bin
36+
cd $GITHUB_WORKSPACE
37+
git clone https://github.com/nats-io/nats-server.git
38+
cd nats-server
39+
go build -o ~/.local/bin/nats-server
2940
nats-server -v
3041
- name: Check out code
31-
uses: actions/checkout@v3
42+
uses: actions/checkout@v4
3243
- name: Build and Test
33-
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
44+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
3445
- name: Verify Javadoc
3546
run: ./gradlew javadoc
36-
- name: Verify and Publish Snapshot
47+
- name: Send coverage to Coveralls
48+
uses: coverallsapp/github-action@v2
49+
with:
50+
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
51+
- name: Publish Snapshot
3752
run: ./gradlew -i publishToSonatype
53+
- name: Clean up
54+
if: always()
55+
run: pkill -9 nats-server 2>/dev/null || true

.github/workflows/build-pr.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,38 @@ jobs:
1111
BUILD_EVENT: ${{ github.event_name }}
1212
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1313
steps:
14-
- name: Setup JDK 8
15-
uses: actions/setup-java@v3
14+
- name: Setup JDK
15+
uses: actions/setup-java@v5
1616
with:
17-
java-version: '8'
18-
distribution: 'adopt'
17+
java-version: '21'
18+
distribution: 'temurin'
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
with:
22+
gradle-version: '8.14' # Quotes required to prevent YAML converting to number
23+
- name: Setup GO
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: stable
1927
- name: Install Nats Server
2028
run: |
21-
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
22-
sudo mv nats-server /usr/local/bin
29+
pkill -9 nats-server 2>/dev/null || true
30+
mkdir -p ~/.local/bin
31+
cd $GITHUB_WORKSPACE
32+
git clone https://github.com/nats-io/nats-server.git
33+
cd nats-server
34+
go build -o ~/.local/bin/nats-server
2335
nats-server -v
2436
- name: Check out code
25-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
2638
- name: Build and Test
27-
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
39+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
2840
- name: Verify Javadoc
2941
run: ./gradlew javadoc
42+
- name: Send coverage to Coveralls
43+
uses: coverallsapp/github-action@v2
44+
with:
45+
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
46+
- name: Clean up
47+
if: always()
48+
run: pkill -9 nats-server 2>/dev/null || true

.github/workflows/build-release.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,35 @@ jobs:
1717
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
1818
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
1919
steps:
20-
- name: Setup JDK 8
21-
uses: actions/setup-java@v3
20+
- name: Setup JDK
21+
uses: actions/setup-java@v4
2222
with:
23-
java-version: '8'
24-
distribution: 'adopt'
23+
java-version: '21'
24+
distribution: 'temurin'
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
27+
with:
28+
gradle-version: '8.14' # Quotes required to prevent YAML converting to number
29+
- name: Setup GO
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: stable
2533
- name: Install Nats Server
2634
run: |
27-
curl -sf https://binaries.nats.dev/nats-io/nats-server/v2@main | PREFIX=. sh
28-
sudo mv nats-server /usr/local/bin
35+
pkill -9 nats-server 2>/dev/null || true
36+
mkdir -p ~/.local/bin
37+
cd $GITHUB_WORKSPACE
38+
git clone https://github.com/nats-io/nats-server.git
39+
cd nats-server
40+
go build -o ~/.local/bin/nats-server
2941
nats-server -v
3042
- name: Check out code
31-
uses: actions/checkout@v3
43+
uses: actions/checkout@v4
3244
- name: Build and Test
3345
run: chmod +x gradlew && ./gradlew clean test
34-
- name: Verify Javadoc
35-
run: ./gradlew javadoc
3646
- name: Verify, Sign and Publish Release
37-
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository
47+
run: ./gradlew -i publishToSonatype closeAndReleaseSonatypeStagingRepository
48+
- name: Clean up
49+
if: always()
50+
run: pkill -9 nats-server 2>/dev/null || true
51+

build.gradle

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import org.gradle.internal.os.OperatingSystem
1+
import aQute.bnd.gradle.Bundle
22

33
plugins {
4-
id 'java'
5-
id 'java-library'
6-
id 'maven-publish'
7-
id 'jacoco'
8-
id 'com.github.kt3k.coveralls' version '2.12.0'
9-
id "org.gradle.test-retry" version "1.1.9"
10-
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
11-
id 'signing'
4+
id("java")
5+
id("java-library")
6+
id("maven-publish")
7+
id("jacoco")
8+
id("biz.aQute.bnd.builder") version "7.1.0"
9+
id("org.gradle.test-retry") version "1.6.4"
10+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
11+
id("signing")
1212
}
1313

14-
def jarVersion = "2.0.2"
14+
def jarVersion = "2.1.0"
1515
group = 'io.nats'
1616

17-
def isMerge = System.getenv("BUILD_EVENT") == "push"
1817
def isRelease = System.getenv("BUILD_EVENT") == "release"
1918

2019
// version is the variable the build actually uses.
@@ -27,81 +26,85 @@ java {
2726

2827
repositories {
2928
mavenCentral()
30-
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
29+
maven { url="https://repo1.maven.org/maven2/" }
30+
maven { url="https://central.sonatype.com/repository/maven-snapshots/" }
3131
}
3232

3333
dependencies {
34-
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
35-
testImplementation 'com.github.stefanbirkner:system-lambda:1.2.1'
36-
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.12.3'
34+
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'
35+
testImplementation 'nl.jqno.equalsverifier:equalsverifier:4.2.1'
36+
37+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
38+
}
39+
40+
tasks.register('bundle', Bundle) {
41+
from sourceSets.main.output
42+
}
43+
44+
jar {
45+
bundle {
46+
bnd("Bundle-Name": "io.nats.jnats.server.runner",
47+
"Bundle-Vendor": "nats.io",
48+
"Bundle-Description": "NATS.IO Java Server Runner",
49+
"Bundle-DocURL": "https://github.com/nats-io/java-nats-server-runner"
50+
)
51+
}
3752
}
3853

3954
test {
4055
useJUnitPlatform()
56+
testLogging {
57+
exceptionFormat = 'full'
58+
events "started", "passed", "skipped", "failed"
59+
showStandardStreams = true
60+
}
61+
retry {
62+
failOnPassedAfterRetry = false
63+
maxFailures = 4
64+
maxRetries = 4
65+
}
66+
systemProperty 'junit.jupiter.execution.timeout.default', '3m'
4167
}
4268

4369
javadoc {
4470
options.overview = 'src/main/javadoc/overview.html' // relative to source root
4571
source = sourceSets.main.allJava
4672
title = "NATS.IO Java Server Runner"
4773
classpath = sourceSets.main.runtimeClasspath
48-
doLast {
49-
if (!OperatingSystem.current().isWindows()) {
50-
exec {
51-
println "Updating favicon on all html files"
52-
workingDir 'build/docs/javadoc'
53-
// Only on linux, mac at this point
54-
commandLine 'find', '.', '-name', '*.html', '-exec', 'sed', '-i', '-e', 's#<head>#<head><link rel="icon" type="image/ico" href="favicon.ico">#', '{}', ';'
55-
}
56-
copy {
57-
println "Copying images to javadoc folder"
58-
from 'src/main/javadoc/images'
59-
into 'build/docs/javadoc'
60-
}
61-
}
62-
}
6374
}
6475

65-
task javadocJar(type: Jar) {
76+
tasks.register('javadocJar', Jar) {
6677
archiveClassifier.set('javadoc')
6778
from javadoc
6879
}
6980

70-
task sourcesJar(type: Jar) {
81+
tasks.register('sourcesJar', Jar) {
7182
archiveClassifier.set('sources')
7283
from sourceSets.main.allSource
7384
}
7485

86+
artifacts {
87+
archives javadocJar, sourcesJar
88+
}
89+
7590
jacoco {
76-
toolVersion = "0.8.6"
91+
toolVersion = "0.8.12"
7792
}
7893

7994
jacocoTestReport {
8095
reports {
81-
xml.enabled = true // coveralls plugin depends on xml format report
82-
html.enabled = true
83-
}
84-
afterEvaluate { // only report on main library not examples
85-
classDirectories.setFrom(files(classDirectories.files.collect {
86-
fileTree(dir: it,
87-
exclude: ['**/examples**'])
88-
}))
96+
xml.required = true // coveralls plugin depends on xml format report
97+
html.required = true
8998
}
9099
}
91100

92-
artifacts {
93-
archives javadocJar, sourcesJar
94-
}
95-
96-
if (isMerge || isRelease) {
97-
nexusPublishing {
98-
repositories {
99-
sonatype {
100-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
101-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
102-
username = System.getenv('OSSRH_USERNAME')
103-
password = System.getenv('OSSRH_PASSWORD')
104-
}
101+
nexusPublishing {
102+
repositories {
103+
sonatype {
104+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
105+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
106+
username = System.getenv('OSSRH_USERNAME')
107+
password = System.getenv('OSSRH_PASSWORD')
105108
}
106109
}
107110
}
@@ -113,11 +116,11 @@ publishing {
113116
artifact sourcesJar
114117
artifact javadocJar
115118
pom {
116-
name = rootProject.name
117-
packaging = 'jar'
119+
name = "jnats-server-runner"
120+
packaging = "jar"
118121
groupId = group
119-
artifactId = archivesBaseName
120-
description = 'Java NATS.io server runner.'
122+
artifactId = "jnats-server-runner"
123+
description = "Java NATS.io server runner."
121124
url = 'https://github.com/nats-io/java-nats-server-runner'
122125
licenses {
123126
license {

gradle/libs.versions.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
3+
4+
[versions]
5+
commons-math3 = "3.6.1"
6+
guava = "33.4.5-jre"
7+
junit-jupiter = "5.12.1"
8+
9+
[libraries]
10+
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
11+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
12+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }

gradle/wrapper/gradle-wrapper.jar

-14.6 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)