-
Notifications
You must be signed in to change notification settings - Fork 57
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
fix: Allow to use environment executable java to launch servers #1263
Conversation
extension/src/util/config.ts
Outdated
return getConfigGradleJavaHome() || process.env.JAVA_HOME; | ||
} | ||
|
||
export async function checkEnvJavaExecutable(): Promise<boolean> { |
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 don't see any async statements in the body.
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.
Let me remove "async" of this function and getGradleServerEnv()
.
const env = { ...process.env }; | ||
if (javaHome) { | ||
Object.assign(env, { | ||
VSCODE_JAVA_HOME: javaHome, | ||
}); | ||
} else if (!(await checkEnvJavaExecutable())) { | ||
return undefined; |
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.
what will happen if undefined
is returned? compared with previous behavior where env
is returned.
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.
prompt NO_JAVA_EXECUTABLE early before actually executing it?
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.
prompt NO_JAVA_EXECUTABLE early before actually executing it?
Yes. Please refer: https://github.com/microsoft/vscode-gradle/pull/1263/files#diff-3369ade313508c278005bfe83330cb8fb4852a75783f5f5843d8d89a46423fc6R43-R46, if we can't find a proper java executable, will return early.
The previous behavior is always to run the start script via cmd
variable, in this way, Gradle will report an error if no java executable can be found.
@@ -53,30 +54,24 @@ export async function startLanguageServer( | |||
serverOptions = awaitServerConnection.bind(null, port); | |||
} else { | |||
// keep consistent with gRPC server | |||
const javaHome = getConfigGradleJavaHome() || process.env.JAVA_HOME; | |||
const javaHome = getJavaHome(); | |||
let javaCommand; | |||
if (!javaHome) { |
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.
Just 2 cents, flip the if-else branch would be more human-readable for me, because you don't assign a new javaHome
in if !javaHome
block..
Below makes more sense to me:
a)
if (!javaHome) {
javaHome = .....
// do something requiring javaHome
} else {
// do something requiring javaHome
}
b)
if (javaHome) {
// do something requiring javaHome
} else {
// do something unrelated with javaHome
}
fix #1249
This pr checks and keeps the consistent of the two servers (Gradle server and Gradle language server), and follow Gradle behavior.
We will check the following ones (with descent priority), Beside VS Code configuration, we use step 4-5 to keep consistent with Gradle itself behavior.