|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
2 | 2 | // Licensed under the MIT license. |
3 | 3 |
|
| 4 | +import { findRuntimes, IJavaRuntime } from "jdk-utils"; |
4 | 5 | import * as _ from "lodash"; |
5 | 6 | import * as path from "path"; |
6 | 7 | import * as vscode from "vscode"; |
7 | 8 | import { getExtensionContext, getNonce } from "../utils"; |
8 | | -import { findJavaHomes, JAVAC_FILENAME, JavaRuntime, verifyJavaHome } from "./utils/findJavaRuntime"; |
9 | | -import { resolveRequirements } from "./utils/upstreamApi"; |
| 9 | +import { getProjectNameFromUri, getProjectType } from "../utils/jdt"; |
| 10 | +import { ProjectType } from "../utils/webview"; |
10 | 11 | import { JavaRuntimeEntry, ProjectRuntimeEntry } from "./types"; |
| 12 | +import { JAVAC_FILENAME, verifyJavaHome } from "./utils/findJavaRuntime"; |
11 | 13 | import { sourceLevelDisplayName } from "./utils/misc"; |
12 | | -import { ProjectType } from "../utils/webview"; |
13 | | -import { getProjectNameFromUri, getProjectType } from "../utils/jdt"; |
| 14 | +import { resolveRequirements } from "./utils/upstreamApi"; |
14 | 15 |
|
15 | 16 | let javaRuntimeView: vscode.WebviewPanel | undefined; |
16 | | -let javaHomes: JavaRuntime[]; |
| 17 | +let javaHomes: IJavaRuntime[]; |
17 | 18 |
|
18 | 19 | export async function javaRuntimeCmdHandler(context: vscode.ExtensionContext, _operationId: string) { |
19 | 20 | if (javaRuntimeView) { |
@@ -211,13 +212,14 @@ export async function findJavaRuntimeEntries(): Promise<{ |
211 | 212 | javaHomeError?: string; |
212 | 213 | }> { |
213 | 214 | if (!javaHomes) { |
214 | | - javaHomes = await findJavaHomes(); |
| 215 | + const runtimes: IJavaRuntime[] = await findRuntimes({checkJavac: true, withVersion: true}); |
| 216 | + javaHomes = runtimes.filter(r => r.hasJavac); |
215 | 217 | } |
216 | 218 | const javaRuntimes: JavaRuntimeEntry[] = javaHomes.map(elem => ({ |
217 | | - name: elem.home, |
218 | | - fspath: elem.home, |
219 | | - majorVersion: elem.version, |
220 | | - type: elem.sources.join(","), |
| 219 | + name: elem.homedir, |
| 220 | + fspath: elem.homedir, |
| 221 | + majorVersion: elem.version?.major || 0, |
| 222 | + type: "from jdk-utils" |
221 | 223 | })).sort((a, b) => b.majorVersion - a.majorVersion); |
222 | 224 |
|
223 | 225 | let javaDotHome; |
|
0 commit comments