From 0f59487f1a5bffb572f6745f7a757c847fb3bf6c Mon Sep 17 00:00:00 2001 From: Shi Chen Date: Tue, 7 Mar 2023 13:27:28 +0800 Subject: [PATCH] feat: Support java 19 (#1319) --- .github/workflows/main.yml | 2 +- README.md | 2 +- extension/src/util/config.ts | 2 +- gradle-language-server/build.gradle | 5 ++++- .../java/com/github/badsyntax/gradle/utils/Utils.java | 7 +++++-- .../test/java/com/github/badsyntax/gradle/UtilsTest.java | 9 +++++++++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c74c37c96..bbd0bfb08 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,7 @@ jobs: fail-fast: false matrix: node-version: [16.14.2] - java-version: ["8", "11", "17"] + java-version: ["8", "11", "17", "19"] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index ce8544fcc..2b3377ad5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This VS Code extension provides a visual interface for your Gradle build. You ca ## Requirements - [VS Code >= 1.66.0](https://code.visualstudio.com/download) -- [Java from 8 to 17](https://adoptopenjdk.net/) +- [Java from 8 to 19](https://adoptopenjdk.net/) ## Project Discovery diff --git a/extension/src/util/config.ts b/extension/src/util/config.ts index 613b6cd2b..15629cd3f 100644 --- a/extension/src/util/config.ts +++ b/extension/src/util/config.ts @@ -36,7 +36,7 @@ export async function getSupportedJavaHome(): Promise { const runtime = await getRuntime(javaHome, { withVersion: true }); if (runtime?.version) { // check the JDK version of given java home is supported, otherwise return undefined - return runtime.version.major >= 8 && runtime.version.major <= 17 ? javaHome : undefined; + return runtime.version.major >= 8 && runtime.version.major <= 19 ? javaHome : undefined; } } return undefined; diff --git a/gradle-language-server/build.gradle b/gradle-language-server/build.gradle index 8a2e2eb6a..7e6f85697 100644 --- a/gradle-language-server/build.gradle +++ b/gradle-language-server/build.gradle @@ -10,6 +10,9 @@ java { repositories { mavenCentral() + maven { + url "https://groovy.jfrog.io/artifactory/plugins-release" + } } application { @@ -20,7 +23,7 @@ application { dependencies { implementation "org.eclipse.lsp4j:org.eclipse.lsp4j:0.12.0" implementation "org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.12.0" - implementation "org.codehaus.groovy:groovy-eclipse-batch:3.0.8-01" + implementation "org.codehaus.groovy:groovy-eclipse-batch:4.0.9-02" implementation "com.google.code.gson:gson:2.8.9" implementation "org.apache.bcel:bcel:6.6.1" testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1" diff --git a/gradle-server/src/main/java/com/github/badsyntax/gradle/utils/Utils.java b/gradle-server/src/main/java/com/github/badsyntax/gradle/utils/Utils.java index f1c0b0397..ae3aee054 100644 --- a/gradle-server/src/main/java/com/github/badsyntax/gradle/utils/Utils.java +++ b/gradle-server/src/main/java/com/github/badsyntax/gradle/utils/Utils.java @@ -18,8 +18,11 @@ public static boolean hasCompatibilityError(Version gradleVersion, Version javaV private static Version getLowestGradleVersion(Version javaVersion) { // Ref: https://docs.gradle.org/current/userguide/compatibility.html - if (javaVersion.isAtLeast("17")) { - // See: https://docs.gradle.org/7.3-rc-3/release-notes.html#java17 + if (javaVersion.isAtLeast("19")) { + return new Version("7.6"); + } else if (javaVersion.isAtLeast("18")) { + return new Version("7.5"); + } else if (javaVersion.isAtLeast("17")) { return new Version("7.3"); } else if (javaVersion.isAtLeast("16")) { return new Version("7.0"); diff --git a/gradle-server/src/test/java/com/github/badsyntax/gradle/UtilsTest.java b/gradle-server/src/test/java/com/github/badsyntax/gradle/UtilsTest.java index 520067655..ef1a6efc8 100644 --- a/gradle-server/src/test/java/com/github/badsyntax/gradle/UtilsTest.java +++ b/gradle-server/src/test/java/com/github/badsyntax/gradle/UtilsTest.java @@ -12,6 +12,15 @@ public class UtilsTest { + @Test + public void testJava19Compatibility() { + Version javaVersion = new Version("19.0.1"); + Version gradleVersion = new Version("7.6.0"); + assertFalse(Utils.hasCompatibilityError(gradleVersion, javaVersion)); + gradleVersion = new Version("7.5.0"); + assertTrue(Utils.hasCompatibilityError(gradleVersion, javaVersion)); + } + @Test public void testJava17Compatibility() { Version javaVersion = new Version("17.0.1");