Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
build:
strategy:
matrix:
jdk: [ 21, 25 ]
tc: [ 8, 17, 21, 25 ]
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
TARGET_COMPATIBILITY: ${{ matrix.tc }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
Expand All @@ -24,7 +24,7 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.jdk }}
java-version: 25
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
Expand All @@ -41,7 +41,7 @@ jobs:
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
parallel: true
flag-name: jdk-${{ matrix.jdk }}
flag-name: tc${{ matrix.tc }}
- name: Publish Snapshot
run: ./gradlew -i publishToSonatype

Expand All @@ -54,4 +54,4 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: "jdk-21"
carryforward: "tc8"
10 changes: 5 additions & 5 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
build:
strategy:
matrix:
jdk: [ 21, 25 ]
tc: [ 8, 17, 21, 25 ]
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
TARGET_COMPATIBILITY: ${{ matrix.tc }}
steps:
- name: Setup JDK
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.jdk }}
java-version: 25
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
Expand All @@ -35,7 +35,7 @@ jobs:
with:
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
parallel: true
flag-name: jdk-${{ matrix.jdk }}
flag-name: tc${{ matrix.tc }}

coveralls-finish:
needs: build
Expand All @@ -46,4 +46,4 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: "jdk-21"
carryforward: "tc8"
16 changes: 7 additions & 9 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
build:
strategy:
matrix:
jdk: [ 21, 25 ]
tc: [ 8, 17, 21, 25 ]
runs-on: ubuntu-latest
env:
BUILD_EVENT: ${{ github.event_name }}
TARGET_COMPATIBILITY: ${{ matrix.jdk }}
TARGET_COMPATIBILITY: ${{ matrix.tc }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
Expand All @@ -25,17 +25,15 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.jdk }}
java-version: 25
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
gradle-version: current
- name: Check out code
uses: actions/checkout@v4
- name: Build and Test
run: chmod +x gradlew && ./gradlew clean test
- name: Verify Javadoc
run: ./gradlew javadoc
- name: Verify, Sign and Publish Release
run: ./gradlew -i publishToSonatype closeAndReleaseSonatypeStagingRepository
- name: Prepare Gradle Script
run: chmod +x gradlew && ./gradlew
- name: Build, Sign and Publish Release
run: ./gradlew clean compileJava publishToSonatype closeAndReleaseSonatypeStagingRepository
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,34 @@ It has been extracted and repackaged from the JNATS library since it is also use

[![Build Main Badge](https://github.com/nats-io/jnats-json/actions/workflows/build-main.yml/badge.svg?event=push)](https://github.com/nats-io/jnats-json/actions/workflows/build-main.yml)
[![Coverage Status](https://coveralls.io/repos/github/nats-io/jnats-json/badge?branch=main)](https://coveralls.io/github/nats-io/jnats-json?branch=main)
[![Maven JDK 21](https://img.shields.io/maven-central/v/io.nats/jnats-json-jdk21?label=maven-central-jdk21)](https://mvnrepository.com/artifact/io.nats/jnats-json-jdk21)
[![Maven JDK 21](https://img.shields.io/maven-central/v/io.nats/jnats-json?label=maven-central)](https://mvnrepository.com/artifact/io.nats/jnats-json)
[![Maven JDK 25](https://img.shields.io/maven-central/v/io.nats/jnats-json-jdk25?label=maven-central-jdk25)](https://mvnrepository.com/artifact/io.nats/jnats-json-jdk25)
[![Javadoc](http://javadoc.io/badge/io.nats/jnats-json-jdk21.svg?branch=main)](http://javadoc.io/doc/io.nats/jnats-json-jdk21?branch=main)
[![Javadoc](http://javadoc.io/badge/io.nats/jnats-json.svg?branch=main)](http://javadoc.io/doc/io.nats/jnats-json?branch=main)
[![License Apache 2](https://img.shields.io/badge/License-Apache2-blue)](https://www.apache.org/licenses/LICENSE-2.0)

### JDK Version

This project uses Java 21 Language Level api, but builds with both Java 21 and Java 25, so creates two different artifacts.
Both have the same group id `io.nats`, and the same version but have different artifact names.
This project uses Java 8 Language Level api, but builds jars compiled with and targeted for Java 8, 17, 21 and 25.
It creates different artifacts for each. All have the same group id `io.nats` and the same version but have different artifact names.

* The Java 21 artifact id is `jnats-json-jdk21`
* The Java 25 artifact id is `jnats-json-jdk25`
| Java Target Level | artifact id |
|:-------------------:|------------------|
| 8 | jnats-json |
| 17 | jnats-json-jdk17 |
| 21 | jnats-json-jdk21 |
| 25 | jnats-json-jdk25 |

### Dependency Management

The NATS client is available in the Maven central repository,
and can be imported as a standard dependency in your `build.gradle` or `pom.xml` file,
The examples shown use the jdk 21 version, to the jdk 25 version just change the artifact id.
The examples shown use the Jdk 8 version. To use other versions, change the artifact id.

#### Gradle

```groovy
dependencies {
implementation 'io.nats:jnats-json-jdk21:3.0.3'
implementation 'io.nats:jnats-json:3.0.3'
}
```

Expand All @@ -60,7 +64,7 @@ repositories {
}

dependencies {
implementation 'io.nats:jnats-json-jdk21:3.0.4-SNAPSHOT'
implementation 'io.nats:jnats-json:3.0.4-SNAPSHOT'
}
```

Expand All @@ -69,7 +73,7 @@ dependencies {
```xml
<dependency>
<groupId>io.nats</groupId>
<artifactId>jnats-json-jdk21</artifactId>
<artifactId>jnats-json</artifactId>
<version>3.0.3</version>
</dependency>
```
Expand Down Expand Up @@ -103,7 +107,7 @@ If you need a snapshot version, you must enable snapshots and change your depend

<dependency>
<groupId>io.nats</groupId>
<artifactId>jnats-json-jdk21</artifactId>
<artifactId>jnats-json</artifactId>
<version>3.0.4-SNAPSHOT</version>
</dependency>
```
Expand Down
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@ plugins {
id("signing")
}

def jarVersion = "3.0.3"
def jarVersion = "3.0.4"
group = 'io.nats'

def isRelease = System.getenv("BUILD_EVENT") == "release"
def tc = System.getenv("TARGET_COMPATIBILITY")
def targetId = tc == "25" ? "25" : "21"
def targetJavaVersion = tc == "25" ? JavaVersion.VERSION_25 : JavaVersion.VERSION_21
def artifact = "jnats-json-jdk" + targetId
def bundleName = "io.nats.jnats.json.jdk" + targetId
def targetJavaVersion = tc == null ? JavaVersion.VERSION_1_8 : JavaVersion.toVersion(tc)
def targetId = targetJavaVersion.toString()
def artifact = "jnats-json" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : "-jdk" + targetId)
def bundleName = "io.nats.jnats.json" + (targetJavaVersion == JavaVersion.VERSION_1_8 ? "" : ".jdk" + targetId)

System.out.println("targetCompatibility: " + targetId)
System.out.println("artifact: " + artifact)
System.out.println("bundleName: " + bundleName)

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

java {
sourceCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = targetJavaVersion
withSourcesJar()
withJavadocJar()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/nats/json/ArrayBuilder.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2025-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/io/nats/json/DateTimeUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2020-2025 The NATS Authors
//
// Modifications Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2020-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/io/nats/json/Encoding.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2020-2025 The NATS Authors
//
// Modifications Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2020-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,6 +18,7 @@
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -305,7 +304,7 @@ public static StringBuilder jsonEncode(@NonNull StringBuilder sb, @Nullable Stri
* @param source the input
* @return the decoded URI
*/
public static String uriDecode(@NonNull String source) {
return URLDecoder.decode(source.replace("+", "%2B"), StandardCharsets.UTF_8);
public static String uriDecode(@NonNull String source) throws UnsupportedEncodingException {
return URLDecoder.decode(source.replace("+", "%2B"), StandardCharsets.UTF_8.name());
}
}
4 changes: 1 addition & 3 deletions src/main/java/io/nats/json/JsonParseException.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2023 The NATS Authors
//
// Modifications Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2023-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/io/nats/json/JsonParser.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2023 The NATS Authors
//
// Modifications Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2023-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/io/nats/json/JsonSerializable.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Copyright 2021-2023 The NATS Authors
//
// Modifications Copyright 2025-2026 Synadia Communications, Inc.
// Copyright 2021-2026 The NATS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading