Skip to content

Commit a1fd732

Browse files
authored
fix: tooling JDK requirements and runtime selection for redhat.java 1.57 (#1768)
* fix: align tooling JDK requirements with redhat.java * fix: leave language-server runtime selection to redhat.java * fix: limit runtime guidance to upstream-reported information * test: use state-driven super implementation navigation * fix: preserve manual JDK setup without runtime metadata * test: verify compatible Gradle JDK imports and builds Keep Gradle 8.5 with a JDK 21 daemon and test a real Java 25 project with Gradle 9.8.1. Assert generated import metadata, dependency-backed completion, clean builds, runtime output and target bytecode. Provision matching CLI/JDK paths in CI without changing automatic JVM selection. * fix: preserve project controls and clarify JDK configuration guidance * ci: prepare VSIX overrides once for the UI matrix * test: bind Gradle UI cases to the CI toolchain * test: repair Gradle model configuration and verify IDE health * chore: split CI preparation and navigation coverage into separate PRs * fix: preserve tooling metadata on project inventory errors * fix: align legacy javac-mode JDK requirements with upstream * ci: consolidate Gradle toolchain binding for JDK 21/25/27 * ci: remove extra tool binding and move runtime guidance to wiki
1 parent ea2dd0e commit a1fd732

30 files changed

Lines changed: 1736 additions & 485 deletions

‎.github/skills/uitest/SKILL.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ The repository workflow `.github/workflows/e2e-autotest.yml` builds a branch VSI
7777

7878
Use workflow dispatch when the user asks to validate in CI or across platforms. The `test_plan` input can target a single plan; leave it empty to run all plans.
7979

80+
For `java-gradle`, `java-gradle-java25`, and `java-gradle-java27`, CI uses one Gradle setup and the existing environment-binding mechanism. Java 21/25 helpers read `GRADLE_CI_GRADLE`, their `JAVA21_HOME`/`JAVA25_HOME`, and `AUTOTEST_STAGING_DIR`; the Java 27 helper retains its `JAVA27_CI_GRADLE` contract. CI does not rewrite terminal commands or override the IDE's Gradle home. Actual version, program-output and bytecode assertions remain unchanged. Local helper invocations retain their existing behavior.
81+
82+
For Java 21/25, the same binding exports `ORG_GRADLE_PROJECT_javaRelease` before VS Code starts. Local runs must set that project property as documented in the fixture README. These plans require BSP import, actual Gradle `build`/`run` tasks, and the exact configuration marker in Gradle for Java output; terminal success alone is insufficient. All three Gradle plans reuse the shared artifact collector: terminal diagnostics are staged outside AutoTest's output and archived under `diagnostics/ci/terminal/`, while Gradle/Java output-channel and extension-host logs are archived under `logs/ide/logs/`.

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ jobs:
2525

2626
- run: npm ci
2727

28+
- run: npm test
29+
2830
- run: npm run build

‎.github/workflows/e2e-autotest.yml‎

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ jobs:
179179
"JAVA27_HOME=$target" >> $env:GITHUB_ENV
180180
Write-Host "Java 27 project toolchain: $target"
181181
182-
- name: Setup Gradle for Java 27
183-
if: contains(matrix.plan, 'java27') && contains(matrix.plan, 'gradle')
184-
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
185-
with:
186-
gradle-version: '9.8.1'
187-
188182
- name: Setup Java 25 (for java25 test plans)
189183
if: contains(matrix.plan, 'java25')
190184
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
@@ -196,6 +190,7 @@ jobs:
196190
if: contains(matrix.plan, 'java25')
197191
shell: pwsh
198192
run: |
193+
"JAVA25_HOME=$env:JAVA_HOME" >> $env:GITHUB_ENV
199194
$planFile = "test-plans/${{ matrix.plan }}.yaml"
200195
if ($IsWindows) {
201196
$target = "C:\Program Files\Java\jdk-25"
@@ -219,22 +214,49 @@ jobs:
219214
distribution: temurin
220215
java-version: 21
221216

222-
- name: Bind Gradle Java 27 toolchain
223-
if: matrix.plan == 'java-gradle-java27'
217+
- name: Configure JDK 21 for Gradle import tests
218+
if: matrix.plan == 'java-gradle' || matrix.plan == 'java-gradle-java25'
224219
shell: pwsh
220+
run: |
221+
"JAVA21_HOME=$env:JAVA_HOME" >> $env:GITHUB_ENV
222+
if ("${{ matrix.plan }}" -eq "java-gradle") {
223+
$planFile = "test-plans/${{ matrix.plan }}.yaml"
224+
# JSON escaping also handles Windows installation paths in double-quoted YAML.
225+
$jdkPath = ($env:JAVA_HOME | ConvertTo-Json -Compress).Trim('"')
226+
(Get-Content $planFile -Raw).Replace('C:\\Program Files\\Java\\jdk-21', $jdkPath) | Set-Content $planFile
227+
}
228+
229+
- name: Setup Gradle for import tests
230+
if: matrix.plan == 'java-gradle' || matrix.plan == 'java-gradle-java25' || matrix.plan == 'java-gradle-java27'
231+
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
232+
with:
233+
gradle-version: ${{ matrix.plan == 'java-gradle' && '8.5' || '9.8.1' }}
234+
235+
- name: Bind Gradle for import tests
236+
if: matrix.plan == 'java-gradle' || matrix.plan == 'java-gradle-java25' || matrix.plan == 'java-gradle-java27'
237+
shell: pwsh
238+
env:
239+
GRADLE_TEST_PLAN: ${{ matrix.plan }}
225240
run: |
226241
$ciGradle = (Get-Command gradle -CommandType Application -ErrorAction Stop | Select-Object -First 1).Source
227-
$versionLog = Join-Path $env:AUTOTEST_STAGING_DIR "gradle-version.log"
228-
$PSNativeCommandUseErrorActionPreference = $false
229-
$gradleVersion = & $ciGradle --version 2>&1 | Out-String
230-
$versionExit = $LASTEXITCODE
231-
"Command: $ciGradle --version`n$gradleVersion" | Set-Content -LiteralPath $versionLog
232-
if ($versionExit -ne 0) { throw "CI Gradle version probe exited with $versionExit; see diagnostics/ci/gradle-version.log in this case's results artifact." }
233-
if ($gradleVersion -notmatch '(?m)^Gradle 9\.8\.1\s*$') {
234-
throw "CI did not select the provisioned Gradle 9.8.1: $ciGradle; see $versionLog"
242+
$release = if ($env:GRADLE_TEST_PLAN -eq "java-gradle") { "21" } elseif ($env:GRADLE_TEST_PLAN -eq "java-gradle-java25") { "25" } else { "27" }
243+
if ($release -eq "27") {
244+
$versionLog = Join-Path $env:AUTOTEST_STAGING_DIR "gradle-version.log"
245+
$PSNativeCommandUseErrorActionPreference = $false
246+
$gradleVersion = & $ciGradle --version 2>&1 | Out-String
247+
$versionExit = $LASTEXITCODE
248+
"Command: $ciGradle --version`n$gradleVersion" | Set-Content -LiteralPath $versionLog
249+
if ($versionExit -ne 0) { throw "CI Gradle version probe exited with $versionExit; see diagnostics/ci/gradle-version.log in this case's results artifact." }
250+
if ($gradleVersion -notmatch '(?m)^Gradle 9\.8\.1\s*$') {
251+
throw "CI did not select the provisioned Gradle 9.8.1: $ciGradle; see $versionLog"
252+
}
253+
"JAVA27_CI_GRADLE=$ciGradle" >> $env:GITHUB_ENV
254+
} else {
255+
"ORG_GRADLE_PROJECT_javaRelease=$release" >> $env:GITHUB_ENV
235256
}
236-
"JAVA27_CI_GRADLE=$ciGradle" >> $env:GITHUB_ENV
237-
Write-Host "Bound Gradle 9.8.1: $ciGradle"
257+
"GRADLE_CI_GRADLE=$ciGradle" >> $env:GITHUB_ENV
258+
"GRADLE_CI_JAVA_HOME=$([Environment]::GetEnvironmentVariable("JAVA${release}_HOME"))" >> $env:GITHUB_ENV
259+
Write-Host "Bound CI Gradle: $ciGradle"
238260
239261
- name: Setup virtual display (Linux)
240262
if: runner.os == 'Linux'
@@ -429,8 +451,8 @@ jobs:
429451
run: |
430452
$identity = [ordered]@{
431453
javaHome = $env:JAVA_HOME
432-
projectJavaHome = $env:JAVA27_HOME
433-
gradle = $env:JAVA27_CI_GRADLE
454+
projectJavaHome = $(if ($env:GRADLE_CI_JAVA_HOME) { $env:GRADLE_CI_JAVA_HOME } else { $env:JAVA27_HOME })
455+
gradle = $env:GRADLE_CI_GRADLE
434456
runnerOs = $env:RUNNER_OS
435457
runnerArch = $env:RUNNER_ARCH
436458
path = $env:PATH

‎.vscodeignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ scripts
1818
test-fixtures/**
1919
test-plans/**
2020
test-results/**
21+
tests/**

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ At the same time, [📦 CheckStyle](https://marketplace.visualstudio.com/items?i
6363

6464
## Questions & Issues
6565

66+
See the [Java runtime requirements and configuration](https://github.com/microsoft/vscode-java-pack/wiki/Java-Runtime-Requirements) guide for JDK setup details.
67+
6668
Each extension mentioned above is a separate open-source project and has its own repository. To make things easier, simply [🙋 open an issue in this repository](https://github.com/Microsoft/vscode-java-pack/issues). The new issue will be triaged and redirected.
6769

6870
## Data/Telemetry

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@
338338
"compile": "webpack --config webpack.config.js",
339339
"watch": "webpack --config webpack.config.js --watch",
340340
"build": "webpack --config webpack.config.js --mode=\"production\"",
341+
"test": "node --test",
341342
"update-tpn": "node scripts/update-third-party-notice.js"
342343
},
343344
"devDependencies": {

‎src/beginner-tips/assets/BeginnerTips.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import DebuggingPanel from "./tabs/DebuggingPanel";
1010
import FaqPanel from "./tabs/FaqPanel";
1111
import QuickStartPanel from "./tabs/QuickStartPanel";
1212

13-
export default function BeginnerTips() {
13+
export default function BeginnerTips({ requiredJdkVersion }: { requiredJdkVersion: number }) {
1414

1515
return (
1616
<div className="container mt-5 mb-5">
@@ -33,7 +33,7 @@ export default function BeginnerTips() {
3333
<DebuggingPanel />
3434
</vscode-tab-panel>
3535
<vscode-tab-panel>
36-
<FaqPanel />
36+
<FaqPanel requiredJdkVersion={requiredJdkVersion} />
3737
</vscode-tab-panel>
3838
</vscode-tabs>
3939
</div>

‎src/beginner-tips/assets/index.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
import { createRoot } from 'react-dom/client';
55
import BeginnerTips from "./BeginnerTips";
66

7-
const root = createRoot(document.getElementById('root')!);
8-
root.render(<BeginnerTips />);
7+
const container = document.getElementById('root')!;
8+
const root = createRoot(container);
9+
root.render(<BeginnerTips requiredJdkVersion={Number(container.dataset.requiredJdkVersion)} />);

‎src/beginner-tips/assets/tabs/FaqPanel.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import "@vscode-elements/elements/dist/vscode-table/index.js";
55
import "@vscode-elements/elements/dist/vscode-table-row/index.js";
66
import "@vscode-elements/elements/dist/vscode-table-cell/index.js";
77
import "@vscode-elements/elements/dist/vscode-table-body/index.js";
8-
const REQUIRED_JDK_VERSION = 17;
8+
import { encodeCommandUriWithTelemetry } from "../../../utils/webview";
99

10-
export default function FaqPanel() {
10+
export default function FaqPanel({ requiredJdkVersion }: { requiredJdkVersion: number }) {
11+
const toolingSettingsCommand = encodeCommandUriWithTelemetry("java.gettingStarted", "toolingSettings", "workbench.action.openSettings", ["java.jdt.ls.java.home"]);
1112
const runtimeSampleCode = (
1213
<code>
1314
<span>{"\"java.configuration.runtimes\": [{"}</span><br />
@@ -50,12 +51,15 @@ export default function FaqPanel() {
5051

5152
<h2 className="font-weight-light">Why do I see the JDK errors?</h2>
5253
<p>
53-
<strong><code>JDK {REQUIRED_JDK_VERSION}+</code> is required</strong> to run the Java language support (redhat.java) extension! You see this error because we failed to find one on your machine. The <a href="command:java.runtime">Configure Java Runtime</a> guide can help you understand how JDK path is searched and provides download links if you need to install one.
54+
<strong><code>JDK {requiredJdkVersion}+</code> is required</strong> to run the installed Java language support (redhat.java) extension. A compatible bundled runtime can satisfy this requirement; otherwise, a compatible local JDK is needed. To set the language-server launch JDK explicitly, configure <a href={toolingSettingsCommand}><code>java.jdt.ls.java.home</code></a>. Runtime selection and startup diagnostics are provided by redhat.java; <a href="command:java.open.logs">open the Java logs</a> for details.
55+
</p>
56+
<p>
57+
The <a href="command:java.runtime">Configure Java Runtime</a> page configures project JDKs, not the language-server launch JDK. Your projects can use older JDKs independently of the tooling requirement.
5458
</p>
5559

5660
<h2 className="font-weight-light">Can I run my Java 8 project with JDK 1.8?</h2>
5761
<p>
58-
Yes. The JDK {REQUIRED_JDK_VERSION} requirement is just for running the Java language support (redhat.java) extension itself. You can still configure a different runtime <a href="command:java.helper.openUrl?%22https%3A%2F%2Fcode.visualstudio.com%2Fdocs%2Fjava%2Fjava-project%23_jdk-for-projects%22">JDK for your project</a> via the user setting <a href="command:workbench.action.openSettings?%22java.configuration.runtimes%22">"java.configuration.runtimes"</a>. The extension will pick a matching JDK to compile/run your project according to the compiler version specified by the project build file.
62+
Yes. The JDK {requiredJdkVersion} requirement is just for running the Java language support (redhat.java) extension itself. You can still configure a different runtime <a href="command:java.helper.openUrl?%22https%3A%2F%2Fcode.visualstudio.com%2Fdocs%2Fjava%2Fjava-project%23_jdk-for-projects%22">JDK for your project</a> via the user setting <a href="command:workbench.action.openSettings?%22java.configuration.runtimes%22">"java.configuration.runtimes"</a>. The extension will pick a matching JDK to compile/run your project according to the compiler version specified by the project build file.
5963
</p>
6064
<blockquote className="card-body">
6165
{runtimeSampleCode}

‎src/beginner-tips/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as path from "path";
55
import * as vscode from "vscode";
66
import { sendInfo } from "vscode-extension-telemetry-wrapper";
77
import { getNonce, webviewCmdLinkHandler } from "../utils";
8+
import { getRequiredJdkVersion } from "../java-runtime/utils/upstreamApi";
89

910
const WEBVIEW_ID = "java.gettingStarted";
1011
const WEBVIEW_TITLE = "Tips for Beginners";
@@ -122,7 +123,7 @@ class BeginnerTipsPage {
122123
</head>
123124
<body>
124125
<noscript>You need to enable JavaScript to run this app.</noscript>
125-
<div id="root"></div>
126+
<div id="root" data-required-jdk-version="${getRequiredJdkVersion()}"></div>
126127
127128
<script nonce="${nonce}" src="${scriptUri}" type="module"></script>
128129
</body>

0 commit comments

Comments
 (0)