Skip to content

Commit 07582c3

Browse files
authored
Merge pull request #12 from nats-io/move-to-java21
Move To Java 21
2 parents fd5f7e4 + a37dd4b commit 07582c3

File tree

14 files changed

+346
-222
lines changed

14 files changed

+346
-222
lines changed

.github/workflows/build-main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ jobs:
1717
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
1818
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1919
steps:
20-
- name: Setup JDK 8
21-
uses: actions/setup-java@v4
22-
with:
23-
java-version: '8'
24-
distribution: 'adopt'
2520
- name: Check out code
2621
uses: actions/checkout@v4
22+
- name: Setup java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: 'temurin'
26+
java-version: '21'
2727
- name: Build and Test
2828
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
2929
- name: Verify Javadoc
3030
run: ./gradlew javadoc
31-
- name: Verify and Publish Snapshot
31+
- name: Publish Snapshot
3232
run: ./gradlew -i publishToSonatype

.github/workflows/build-pr.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ 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@v4
16-
with:
17-
java-version: '8'
18-
distribution: 'adopt'
1914
- name: Check out code
2015
uses: actions/checkout@v4
16+
- name: Setup java
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: 'temurin'
20+
java-version: '21'
2121
- name: Build and Test
2222
run: chmod +x gradlew && ./gradlew clean test jacocoTestReport coveralls
2323
- name: Verify Javadoc

.github/workflows/build-release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ 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@v4
22-
with:
23-
java-version: '8'
24-
distribution: 'adopt'
2520
- name: Check out code
2621
uses: actions/checkout@v4
22+
- name: Setup java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: 'temurin'
26+
java-version: '21'
2727
- name: Build and Test
2828
run: chmod +x gradlew && ./gradlew clean test
2929
- name: Verify Javadoc

build.gradle

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import org.gradle.internal.os.OperatingSystem
22

33
plugins {
4-
id 'java'
54
id 'java-library'
65
id 'maven-publish'
76
id 'jacoco'
8-
id 'com.github.kt3k.coveralls' version '2.12.0'
7+
id 'com.github.kt3k.coveralls' version '2.12.2'
98
id "org.gradle.test-retry" version "1.1.9"
109
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
1110
id 'signing'
1211
}
1312

14-
def jarVersion = "2.0.2"
13+
def jarVersion = "2.21.0.TEST.1"
1514
group = 'io.nats'
1615

1716
def isMerge = System.getenv("BUILD_EVENT") == "push"
@@ -20,19 +19,24 @@ def isRelease = System.getenv("BUILD_EVENT") == "release"
2019
// version is the variable the build actually uses.
2120
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT"
2221

22+
// Apply a specific Java toolchain to ease working on different environments.
2323
java {
24-
sourceCompatibility = JavaVersion.VERSION_1_8
25-
targetCompatibility = JavaVersion.VERSION_1_8
24+
toolchain {
25+
languageVersion = JavaLanguageVersion.of(21)
26+
}
27+
withJavadocJar()
28+
withSourcesJar()
2629
}
2730

2831
repositories {
2932
mavenCentral()
3033
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
34+
maven { url "https://repo1.maven.org/maven2/" }
3135
}
3236

3337
dependencies {
34-
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
35-
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.12.3'
38+
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
39+
testImplementation 'nl.jqno.equalsverifier:equalsverifier:4.0'
3640
}
3741

3842
test {
@@ -45,9 +49,10 @@ test {
4549
}
4650

4751
javadoc {
52+
options.addBooleanOption('html5', true)
4853
options.overview = 'src/main/javadoc/overview.html' // relative to source root
4954
source = sourceSets.main.allJava
50-
title = "NATS.IO Java NKeys"
55+
title = "NATS.IO JNats JSON"
5156
classpath = sourceSets.main.runtimeClasspath
5257
doLast {
5358
if (!OperatingSystem.current().isWindows()) {
@@ -66,37 +71,6 @@ javadoc {
6671
}
6772
}
6873

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
77-
}
78-
79-
jacoco {
80-
toolVersion = "0.8.6"
81-
}
82-
83-
jacocoTestReport {
84-
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-
}))
93-
}
94-
}
95-
96-
artifacts {
97-
archives javadocJar, sourcesJar
98-
}
99-
10074
if (isMerge || isRelease) {
10175
nexusPublishing {
10276
repositories {
@@ -113,14 +87,18 @@ if (isMerge || isRelease) {
11387
publishing {
11488
publications {
11589
mavenJava(MavenPublication) {
90+
artifactId = archivesBaseName
11691
from components.java
117-
artifact sourcesJar
118-
artifact javadocJar
92+
versionMapping {
93+
usage('java-api') {
94+
fromResolutionOf('runtimeClasspath')
95+
}
96+
usage('java-runtime') {
97+
fromResolutionResult()
98+
}
99+
}
119100
pom {
120-
name = rootProject.name
121-
packaging = 'jar'
122-
groupId = group
123-
artifactId = archivesBaseName
101+
name = 'JNats Json'
124102
description = 'JSON Parser built specifically for JNATS'
125103
url = 'https://github.com/nats-io/nats.java.json'
126104
licenses {
@@ -134,7 +112,7 @@ publishing {
134112
id = "synadia"
135113
name = "Synadia"
136114
email = "info@synadia.com"
137-
url = "https://nats.io"
115+
url = "https://synadia.io"
138116
}
139117
}
140118
scm {
@@ -143,6 +121,14 @@ publishing {
143121
}
144122
}
145123
}
124+
// repositories {
125+
// maven {
126+
// // change URLs to point to your repos, e.g. http://my.org/repo
127+
// def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/"
128+
// def snapshotsRepoUrl = layout.buildDirectory.dir("https://central.sonatype.com/repository/maven-snapshots/")
129+
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
130+
// }
131+
// }
146132
}
147133

148134
if (isRelease) {
@@ -154,4 +140,4 @@ if (isRelease) {
154140
sign configurations.archives
155141
sign publishing.publications.mavenJava
156142
}
157-
}
143+
}

env.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set JAVA_HOME=C:\Program Files\Java\jdk-21
2+
set PATH=C:\Program Files\Java\jdk-21\bin;C:\Programs\gradle-8.14\bin;%PATH%

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)