Skip to content

Commit

Permalink
fix - Gradle server jvm opts alignment (#1541)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaaming authored Jul 31, 2024
1 parent 702d1cc commit 3cfecc8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"order": 2
},
"env": {
"GRADLE_SERVER_OPTS":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8089"
"DEBUG_GRADLE_SERVER": "true",
},
},
{
Expand Down
3 changes: 3 additions & 0 deletions extension/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const NO_JAVA_EXECUTABLE =

export const OPT_RESTART = "Restart";

export const GRADLE_SERVER_BASE_JVM_OPTS =
"--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED";

export enum CompletionKinds {
DEPENDENCY_GROUP = "dependency_group",
DEPENDENCY_ARTIFACT = "dependency_artifact",
Expand Down
7 changes: 7 additions & 0 deletions extension/src/server/serverUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getConfigJavaImportGradleJavaHome,
getRedHatJavaEmbeddedJRE,
} from "../util/config";
import { GRADLE_SERVER_BASE_JVM_OPTS } from "../constant";

export function getGradleServerCommand(): string {
const platform = process.platform;
Expand All @@ -27,6 +28,12 @@ export async function getGradleServerEnv(): Promise<ProcessEnv | undefined> {
Object.assign(env, {
VSCODE_JAVA_HOME: javaHome,
});
if (env["DEBUG_GRADLE_SERVER"] === "true") {
env.GRADLE_SERVER_OPTS =
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8089 " + GRADLE_SERVER_BASE_JVM_OPTS;
} else {
env.GRADLE_SERVER_OPTS = GRADLE_SERVER_BASE_JVM_OPTS;
}
} else if (!checkEnvJavaExecutable()) {
return undefined;
}
Expand Down

0 comments on commit 3cfecc8

Please sign in to comment.