Skip to content

Commit c0bbb5d

Browse files
committed
Upgrade to Java 21 and Gradle 9
1 parent 13a7844 commit c0bbb5d

31 files changed

+4402
-1561
lines changed

.github/workflows/build-main.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,50 @@ on:
77

88
jobs:
99
build:
10+
strategy:
11+
matrix:
12+
jdk: [ 21, 25 ]
1013
runs-on: ubuntu-latest
1114
env:
1215
BUILD_EVENT: ${{ github.event_name }}
16+
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
1317
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
1418
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
1519
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
1620
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
1721
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
18-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1922
steps:
20-
- name: Setup JDK 8
21-
uses: actions/setup-java@v4
23+
- name: Setup JDK
24+
uses: actions/setup-java@v5
2225
with:
23-
java-version: '8'
24-
distribution: 'adopt'
26+
java-version: ${{ matrix.jdk }}
27+
distribution: 'temurin'
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v5
30+
with:
31+
gradle-version: current
2532
- name: Check out code
2633
uses: actions/checkout@v4
2734
- name: Build and Test
28-
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
35+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
2936
- name: Verify Javadoc
3037
run: ./gradlew javadoc
31-
- name: Verify and Publish Snapshot
38+
- name: Send coverage to Coveralls
39+
uses: coverallsapp/github-action@v2
40+
with:
41+
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
42+
parallel: true
43+
flag-name: jdk-${{ matrix.jdk }}
44+
- name: Publish Snapshot
3245
run: ./gradlew -i publishToSonatype
46+
47+
coveralls-finish:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Coveralls Finish
52+
uses: coverallsapp/github-action@v2
53+
with:
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
parallel-finished: true
56+
carryforward: "jdk-21"

.github/workflows/build-pr.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,43 @@ on:
66

77
jobs:
88
build:
9+
strategy:
10+
matrix:
11+
jdk: [ 21, 25 ]
912
runs-on: ubuntu-latest
1013
env:
1114
BUILD_EVENT: ${{ github.event_name }}
12-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
15+
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
1316
steps:
14-
- name: Setup JDK 8
15-
uses: actions/setup-java@v4
17+
- name: Setup JDK
18+
uses: actions/setup-java@v5
1619
with:
17-
java-version: '8'
18-
distribution: 'adopt'
20+
java-version: ${{ matrix.jdk }}
21+
distribution: 'temurin'
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v5
24+
with:
25+
gradle-version: current
1926
- name: Check out code
2027
uses: actions/checkout@v4
2128
- name: Build and Test
22-
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
29+
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport
2330
- name: Verify Javadoc
2431
run: ./gradlew javadoc
32+
- name: Send coverage to Coveralls
33+
uses: coverallsapp/github-action@v2
34+
with:
35+
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
36+
parallel: true
37+
flag-name: jdk-${{ matrix.jdk }}
38+
39+
coveralls-finish:
40+
needs: build
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Coveralls Finish
44+
uses: coverallsapp/github-action@v2
45+
with:
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
parallel-finished: true
48+
carryforward: "jdk-21"

.github/workflows/build-release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,33 @@ on:
88

99
jobs:
1010
build:
11+
strategy:
12+
matrix:
13+
jdk: [ 21, 25 ]
1114
runs-on: ubuntu-latest
1215
env:
1316
BUILD_EVENT: ${{ github.event_name }}
17+
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
1418
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
1519
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
1620
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
1721
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
1822
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
1923
steps:
20-
- name: Setup JDK 8
21-
uses: actions/setup-java@v4
24+
- name: Setup JDK
25+
uses: actions/setup-java@v5
2226
with:
23-
java-version: '8'
24-
distribution: 'adopt'
27+
java-version: ${{ matrix.jdk }}
28+
distribution: 'temurin'
29+
- name: Setup Gradle
30+
uses: gradle/actions/setup-gradle@v5
31+
with:
32+
gradle-version: current
2533
- name: Check out code
2634
uses: actions/checkout@v4
2735
- name: Build and Test
2836
run: chmod +x gradlew && ./gradlew clean test
2937
- name: Verify Javadoc
3038
run: ./gradlew javadoc
3139
- name: Verify, Sign and Publish Release
32-
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository
40+
run: ./gradlew -i publishToSonatype closeAndReleaseSonatypeStagingRepository

build.gradle

Lines changed: 66 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,63 @@
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.2'
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-library")
5+
id("maven-publish")
6+
id("jacoco")
7+
id("biz.aQute.bnd.builder") version "7.2.1"
8+
id("org.gradle.test-retry") version "1.6.4"
9+
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
10+
id("signing")
1211
}
1312

14-
def jarVersion = "2.22.0"
13+
def jarVersion = "3.0.0"
1514
group = 'io.nats'
1615

17-
def isMerge = System.getenv("BUILD_EVENT") == "push"
1816
def isRelease = System.getenv("BUILD_EVENT") == "release"
17+
def tc = System.getenv("TARGET_COMPATIBILITY")
18+
def targetCompat = tc == "25" ? JavaVersion.VERSION_25 : JavaVersion.VERSION_21
19+
def jarEnd = tc == "25" ? "-jdk25" : ""
20+
def bundleEnd = tc == "25" ? ".jdk25" : ""
21+
def jarAndArtifactName = "jnats-json" + jarEnd
22+
def bundleName = "io.nats.jnats.json" + bundleEnd
1923

20-
// version is the variable the build actually uses.
21-
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT"
24+
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the build actually uses.
2225

2326
java {
24-
sourceCompatibility = JavaVersion.VERSION_1_8
25-
targetCompatibility = JavaVersion.VERSION_1_8
27+
sourceCompatibility = JavaVersion.VERSION_21
28+
targetCompatibility = targetCompat
29+
withSourcesJar()
30+
withJavadocJar()
2631
}
2732

2833
repositories {
2934
mavenCentral()
30-
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
35+
maven { url="https://repo1.maven.org/maven2/" }
36+
maven { url="https://central.sonatype.com/repository/maven-snapshots/" }
3137
}
3238

3339
dependencies {
34-
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
35-
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.12.3'
40+
implementation 'org.jspecify:jspecify:1.0.0'
41+
implementation 'commons-codec:commons-codec:1.20.0'
42+
43+
testImplementation 'org.junit.jupiter:junit-jupiter:5.14.1'
44+
45+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
46+
}
47+
48+
tasks.register('bundle', Bundle) {
49+
from sourceSets.main.output
50+
}
51+
52+
jar {
53+
bundle {
54+
bnd("Bundle-Name": bundleName,
55+
"Bundle-Vendor": "nats.io",
56+
"Bundle-Description": "JNats JSON Utility",
57+
"Bundle-DocURL": "https://github.com/nats-io/jnats.json",
58+
"Target-Compatibility": "Java " + targetCompat
59+
)
60+
}
3661
}
3762

3863
test {
@@ -45,35 +70,11 @@ test {
4570
}
4671

4772
javadoc {
73+
failOnError = false
4874
options.overview = 'src/main/javadoc/overview.html' // relative to source root
4975
source = sourceSets.main.allJava
50-
title = "NATS.IO JNats JSON"
76+
title = "JNats JSON Utility"
5177
classpath = sourceSets.main.runtimeClasspath
52-
doLast {
53-
if (!OperatingSystem.current().isWindows()) {
54-
exec {
55-
println "Updating favicon on all html files"
56-
workingDir 'build/docs/javadoc'
57-
// Only on linux, mac at this point
58-
commandLine 'find', '.', '-name', '*.html', '-exec', 'sed', '-i', '-e', 's#<head>#<head><link rel="icon" type="image/ico" href="favicon.ico">#', '{}', ';'
59-
}
60-
copy {
61-
println "Copying images to javadoc folder"
62-
from 'src/main/javadoc/images'
63-
into 'build/docs/javadoc'
64-
}
65-
}
66-
}
67-
}
68-
69-
task javadocJar(type: Jar) {
70-
archiveClassifier.set('javadoc')
71-
from javadoc
72-
}
73-
74-
task sourcesJar(type: Jar) {
75-
archiveClassifier.set('sources')
76-
from sourceSets.main.allSource
7778
}
7879

7980
jacoco {
@@ -82,30 +83,18 @@ jacoco {
8283

8384
jacocoTestReport {
8485
reports {
85-
xml.enabled = true // coveralls plugin depends on xml format report
86-
html.enabled = true
87-
}
88-
afterEvaluate { // only report on main library not examples
89-
classDirectories.setFrom(files(classDirectories.files.collect {
90-
fileTree(dir: it,
91-
exclude: ['**/examples**'])
92-
}))
86+
xml.required = true // coveralls plugin depends on xml format report
87+
html.required = true
9388
}
9489
}
9590

96-
artifacts {
97-
archives javadocJar, sourcesJar
98-
}
99-
100-
if (isMerge || isRelease) {
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')
108-
}
91+
nexusPublishing {
92+
repositories {
93+
sonatype {
94+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
95+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
96+
username = System.getenv('OSSRH_USERNAME')
97+
password = System.getenv('OSSRH_PASSWORD')
10998
}
11099
}
111100
}
@@ -114,31 +103,31 @@ publishing {
114103
publications {
115104
mavenJava(MavenPublication) {
116105
from components.java
117-
artifact sourcesJar
118-
artifact javadocJar
119106
pom {
120-
name = rootProject.name
121-
packaging = 'jar'
107+
name = 'JNats JSON Utility'
108+
description = 'JSON Parser originally built for JNATS'
109+
url = 'https://github.com/nats-io/jnats.json'
110+
122111
groupId = group
123-
artifactId = archivesBaseName
124-
description = 'JSON Parser built specifically for JNATS'
125-
url = 'https://github.com/nats-io/nats.java.json'
112+
artifactId = jarAndArtifactName
113+
126114
licenses {
127115
license {
128116
name = 'The Apache License, Version 2.0'
129117
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
130118
}
131119
}
120+
132121
developers {
133122
developer {
134-
id = "synadia"
135-
name = "Synadia"
136-
email = "info@synadia.com"
137-
url = "https://nats.io"
123+
id = 'synadia'
124+
name = 'Synadia'
125+
email = 'info@synadia.com'
126+
url = 'https://synadia.io'
138127
}
139128
}
140129
scm {
141-
url = 'https://github.com/nats-io/nats.java.json'
130+
url = 'https://github.com/nats-io/jnats.json'
142131
}
143132
}
144133
}

gradle/wrapper/gradle-wrapper.jar

-12.8 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-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)