-
Notifications
You must be signed in to change notification settings - Fork 492
Add command to add JDK to settings #4162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
Signed-off-by: Thomas Mäder <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems mostly fine. Just be aware this overlaps with https://github.com/microsoft/vscode-java-pack/blob/main/src/java-runtime/index.ts and it probably would have been ideal to move that page here.
canSelectMany: false, | ||
title: 'Select JDK Directory', | ||
}); | ||
if (directory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth validating the directory by at least checking ${directory}/bin/javac
exists to ensure it's probably a valid JDK ?
|
||
export namespace JavaRuntimes { | ||
export async function initialize(context: vscode.ExtensionContext): Promise<void> { | ||
context.subscriptions.push(vscode.commands.registerCommand('java.runtimes.add', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably add "java.runtimes.add" to Commands
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rebase against the main branch? JavaSE-25 is available now.
const config = vscode.workspace.getConfiguration('java.configuration').get('runtimes'); | ||
if (Array.isArray(config)) { | ||
if (config.some(r => r.path === directory[0].fsPath)) { | ||
vscode.window.showErrorMessage(`JDK Directory ${directory[0].fsPath} already configured`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (config.some(r => r.path === directory[0].fsPath)) { | ||
vscode.window.showErrorMessage(`JDK Directory ${directory[0].fsPath} already configured`); | ||
} else { | ||
const name = await vscode.window.showQuickPick(getSupportedJreNames(), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would improve it by:
- detecting the java version of the selected path
- preselect the matching execution environment name
- filter out incompatible environments, i.e don't show JavaSE-22 and above if you selected a JDK 21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also pre Java 8 support has been dropped over a year ago. Can you remove the J2SE-1.5 ... JavaSE-7 values in package.json
export namespace JavaRuntimes { | ||
export async function initialize(context: vscode.ExtensionContext): Promise<void> { | ||
context.subscriptions.push(vscode.commands.registerCommand('java.runtimes.add', async () => { | ||
const directory = await vscode.window.showOpenDialog({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe default to parent folder of last selected JDK (just to make my testing easier)
vscode.workspace.getConfiguration('java.configuration').update('runtimes', config, vscode.ConfigurationTarget.Global); | ||
vscode.window.showInformationMessage(`JDK Directory ${directory[0].fsPath} added`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be executed only if the quickpick was complete. If I press ESC while the wizard is open, I see the "...added" message.
This adds a VS Code command that