Skip to content

Commit

Permalink
feat: Support java 19 (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
CsCherrYY committed Mar 27, 2023
1 parent e16d086 commit 0f59487
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion extension/src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function getSupportedJavaHome(): Promise<string | undefined> {
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;
Expand Down
5 changes: 4 additions & 1 deletion gradle-language-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ java {

repositories {
mavenCentral()
maven {
url "https://groovy.jfrog.io/artifactory/plugins-release"
}
}

application {
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 0f59487

Please sign in to comment.