From 8615627c5b4a036a472e52b12bfb2789b47fc103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GREFFIER?= Date: Wed, 14 Feb 2024 17:54:36 +0100 Subject: [PATCH] Ensure Java 21 compatibility (#166) * Ensure Java 21 compatibility * Fix param * Fix readme * fix condition on java17 * Remove deprecated api --- .github/workflows/on_pull_request.yml | 8 +++-- .github/workflows/on_push_main.yml | 10 ++++-- README.md | 2 +- .../converter/JsonToAvroConverter.java | 2 +- pom.xml | 34 +++++++++++++------ 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index a1ca4148..840087f5 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -7,16 +7,19 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + java: [ '17', '21' ] steps: - name: Checkout project uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 17 + - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 with: - java-version: '17' + java-version: ${{ matrix.java }} distribution: 'temurin' cache: maven @@ -36,6 +39,7 @@ jobs: report_paths: '**/target/surefire-reports/TEST-*.xml' - name: Sonar + if: matrix.java == '17' run: mvn verify sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/on_push_main.yml b/.github/workflows/on_push_main.yml index dea27c4d..7a020743 100644 --- a/.github/workflows/on_push_main.yml +++ b/.github/workflows/on_push_main.yml @@ -7,16 +7,19 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + java: [ '17', '21' ] steps: - name: Checkout project uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 17 + - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v4 with: - java-version: '17' + java-version: ${{ matrix.java }} distribution: 'temurin' cache: maven server-id: ossrh @@ -44,13 +47,14 @@ jobs: report_paths: '**/target/surefire-reports/TEST-*.xml' - name: Sonar + if: matrix.java == '17' run: mvn verify sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Deploy - if: endsWith(steps.build.outputs.current_version, '-SNAPSHOT') + if: endsWith(steps.build.outputs.current_version, '-SNAPSHOT') && matrix.java == '17' run: mvn -B deploy -DskipTests -Psign env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/README.md b/README.md index 5b9b093c..2e3fd8b9 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ need to do: ## Dependencies -Kstreamplify offers three dependencies, all compatible with Java 17. +Kstreamplify offers three dependencies, all compatible with Java 17 and 21. ### Java diff --git a/kstreamplify-core/src/main/java/com/michelin/kstreamplify/converter/JsonToAvroConverter.java b/kstreamplify-core/src/main/java/com/michelin/kstreamplify/converter/JsonToAvroConverter.java index 2ae490df..eac2a73a 100644 --- a/kstreamplify-core/src/main/java/com/michelin/kstreamplify/converter/JsonToAvroConverter.java +++ b/kstreamplify-core/src/main/java/com/michelin/kstreamplify/converter/JsonToAvroConverter.java @@ -33,7 +33,7 @@ public class JsonToAvroConverter { * @return the record in avro */ public static SpecificRecordBase jsonToAvro(String file, Schema schema) { - return jsonToAvro((JsonObject) new JsonParser().parse(file), schema); + return jsonToAvro(JsonParser.parseString(file).getAsJsonObject(), schema); } /** diff --git a/pom.xml b/pom.xml index 77b6db07..cc5d304a 100644 --- a/pom.xml +++ b/pom.xml @@ -113,17 +113,22 @@ 1.11.3 + 10.12.7 2.15.1 3.14.0 2.10.1 - 17 5.10.2 - 3.4.0 + 3.6.1 7.6.0 1.18.30 - 17 - 17 5.10.0 + 3.3.1 + 17 + 3.12.1 + 3.1.0 + 3.6.3 + 3.3.0 + 3.2.5 0.8.11 3.2.2 1.19.5 @@ -221,10 +226,19 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.java.version} + + + org.apache.maven.plugins maven-source-plugin - 3.3.0 + ${maven-source-plugin.version} attach-sources @@ -239,7 +253,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + ${maven-javadoc-plugin.version} attach-javadocs @@ -254,7 +268,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + ${maven-surefire-plugin.version} org.junit.jupiter @@ -301,12 +315,12 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.1 + ${maven-checkstyle-plugin.version} com.puppycrawl.tools checkstyle - 10.13.0 + ${checkstyle.version} @@ -363,7 +377,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + ${maven-gpg-plugin.version} sign-artifacts