Skip to content

Commit 6978179

Browse files
committed
Targeting: Java 8, 17, 21, 25
1 parent bf56ff8 commit 6978179

File tree

6 files changed

+51
-45
lines changed

6 files changed

+51
-45
lines changed

.github/workflows/build-main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
jdk: [ 21, 25 ]
13+
tc: [ 8, 17, 21, 25 ]
1414
runs-on: ubuntu-latest
1515
env:
1616
BUILD_EVENT: ${{ github.event_name }}
17-
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
17+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
1818
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
1919
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
2020
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup JDK
2525
uses: actions/setup-java@v5
2626
with:
27-
java-version: ${{ matrix.jdk }}
27+
java-version: 25
2828
distribution: 'temurin'
2929
- name: Setup Gradle
3030
uses: gradle/actions/setup-gradle@v5
@@ -41,7 +41,7 @@ jobs:
4141
with:
4242
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
4343
parallel: true
44-
flag-name: jdk-${{ matrix.jdk }}
44+
flag-name: tc${{ matrix.tc }}
4545
- name: Publish Snapshot
4646
run: ./gradlew -i publishToSonatype
4747

@@ -54,4 +54,4 @@ jobs:
5454
with:
5555
github-token: ${{ secrets.GITHUB_TOKEN }}
5656
parallel-finished: true
57-
carryforward: "jdk-21"
57+
carryforward: "tc8"

.github/workflows/build-pr.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
build:
1010
strategy:
1111
matrix:
12-
jdk: [ 21, 25 ]
12+
tc: [ 8, 17, 21, 25 ]
1313
runs-on: ubuntu-latest
1414
env:
1515
BUILD_EVENT: ${{ github.event_name }}
16-
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
16+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
1717
steps:
1818
- name: Setup JDK
1919
uses: actions/setup-java@v5
2020
with:
21-
java-version: ${{ matrix.jdk }}
21+
java-version: 25
2222
distribution: 'temurin'
2323
- name: Setup Gradle
2424
uses: gradle/actions/setup-gradle@v5
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
3737
parallel: true
38-
flag-name: jdk-${{ matrix.jdk }}
38+
flag-name: tc${{ matrix.tc }}
3939

4040
coveralls-finish:
4141
needs: build
@@ -46,4 +46,4 @@ jobs:
4646
with:
4747
github-token: ${{ secrets.GITHUB_TOKEN }}
4848
parallel-finished: true
49-
carryforward: "jdk-21"
49+
carryforward: "tc8"

.github/workflows/build-release.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
build:
1212
strategy:
1313
matrix:
14-
jdk: [ 21, 25 ]
14+
tc: [ 8, 17, 21, 25 ]
1515
runs-on: ubuntu-latest
1616
env:
1717
BUILD_EVENT: ${{ github.event_name }}
18-
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
18+
TARGET_COMPATIBILITY: ${{ matrix.tc }}
1919
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
2020
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
2121
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
@@ -25,17 +25,15 @@ jobs:
2525
- name: Setup JDK
2626
uses: actions/setup-java@v5
2727
with:
28-
java-version: ${{ matrix.jdk }}
28+
java-version: 25
2929
distribution: 'temurin'
3030
- name: Setup Gradle
3131
uses: gradle/actions/setup-gradle@v5
3232
with:
3333
gradle-version: current
3434
- name: Check out code
3535
uses: actions/checkout@v4
36-
- name: Build and Test
37-
run: chmod +x gradlew && ./gradlew clean test
38-
- name: Verify Javadoc
39-
run: ./gradlew javadoc
40-
- name: Verify, Sign and Publish Release
41-
run: ./gradlew -i publishToSonatype closeAndReleaseSonatypeStagingRepository
36+
- name: Prepare Gradle Script
37+
run: chmod +x gradlew && ./gradlew
38+
- name: Build, Sign and Publish Release
39+
run: ./gradlew clean compileJava publishToSonatype closeAndReleaseSonatypeStagingRepository

build.gradle

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ group = 'io.nats'
1515

1616
def isRelease = System.getenv("BUILD_EVENT") == "release"
1717
def tc = System.getenv("TARGET_COMPATIBILITY")
18-
def targetId = tc == "25" ? "25" : "21"
19-
def targetJavaVersion = tc == "25" ? JavaVersion.VERSION_25 : JavaVersion.VERSION_21
20-
def artifact = "nkeys-java-jdk" + targetId
21-
def bundleName = "io.nats.nkeys.java.jdk" + targetId
18+
def targetJavaVersion = tc == null ? JavaVersion.VERSION_1_8 : JavaVersion.toVersion(tc)
19+
def targetId = targetJavaVersion.toString()
20+
def artifact = "nkeys-java" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : "-jdk" + targetId)
21+
def bundleName = "io.nats.nkeys.java" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : ".jdk" + targetId)
22+
23+
System.out.println("targetCompatibility: " + targetId)
24+
System.out.println("artifact: " + artifact)
25+
System.out.println("bundleName: " + bundleName)
2226

2327
version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT" // version is the variable the gradle uses.
2428

2529
java {
26-
sourceCompatibility = JavaVersion.VERSION_21
30+
sourceCompatibility = JavaVersion.VERSION_1_8
2731
targetCompatibility = targetJavaVersion
2832
withSourcesJar()
2933
withJavadocJar()
@@ -41,6 +45,8 @@ dependencies {
4145

4246
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
4347
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.12.3'
48+
49+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
4450
}
4551

4652
tasks.register('bundle', Bundle) {

src/main/java/io/nats/nkey/NKey.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131

3232
public class NKey {
3333

34-
private static boolean notValidPublicPrefixByte(int prefix) {
35-
return switch (prefix) {
36-
case PREFIX_BYTE_SERVER,
37-
PREFIX_BYTE_CLUSTER,
38-
PREFIX_BYTE_OPERATOR,
39-
PREFIX_BYTE_ACCOUNT,
40-
PREFIX_BYTE_USER -> false;
41-
default -> true;
42-
};
34+
static boolean notValidPublicPrefixByte(int prefix) {
35+
switch (prefix) {
36+
case PREFIX_BYTE_SERVER:
37+
case PREFIX_BYTE_CLUSTER:
38+
case PREFIX_BYTE_OPERATOR:
39+
case PREFIX_BYTE_ACCOUNT:
40+
case PREFIX_BYTE_USER:
41+
return false;
42+
}
43+
return true;
4344
}
4445

4546
static char[] removePaddingAndClear(char[] withPad) {
@@ -466,14 +467,14 @@ public boolean verify(byte[] input, byte[] signature) throws IOException {
466467

467468
@Override
468469
public boolean equals(Object o) {
469-
if (o == this) {
470+
if (o == this)
470471
return true;
471-
}
472-
473-
if (!(o instanceof NKey otherNkey)) {
472+
if (!(o instanceof NKey)) {
474473
return false;
475474
}
476475

476+
NKey otherNkey = (NKey) o;
477+
477478
if (this.type != otherNkey.type) {
478479
return false;
479480
}

src/main/java/io/nats/nkey/NKeyType.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ public enum NKeyType {
5555
}
5656

5757
public static @Nullable NKeyType fromPrefix(int prefix) {
58-
return switch (prefix) {
59-
case PREFIX_BYTE_ACCOUNT, PREFIX_BYTE_PRIVATE -> ACCOUNT;
60-
case PREFIX_BYTE_SERVER -> SERVER;
61-
case PREFIX_BYTE_USER -> USER;
62-
case PREFIX_BYTE_CLUSTER -> CLUSTER;
63-
case PREFIX_BYTE_OPERATOR -> OPERATOR;
64-
default -> null;
65-
};
58+
switch (prefix) {
59+
case PREFIX_BYTE_ACCOUNT:
60+
case PREFIX_BYTE_PRIVATE: return ACCOUNT;
61+
case PREFIX_BYTE_SERVER: return SERVER;
62+
case PREFIX_BYTE_USER: return USER;
63+
case PREFIX_BYTE_CLUSTER: return CLUSTER;
64+
case PREFIX_BYTE_OPERATOR: return OPERATOR;
65+
}
66+
return null;
6667
}
6768
}

0 commit comments

Comments
 (0)