Skip to content
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

bugfix: Add back properties and env when fetching metals #1510

Merged
merged 2 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions packages/metals-languageclient/src/fetchMetals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface PackedChildPromise {
export async function fetchMetals({
serverVersion,
serverProperties,
javaConfig: { coursier, javaPath },
javaConfig: { javaOptions, coursier, extraEnv, javaPath },
outputChannel,
}: FetchMetalsOptions): Promise<PackedChildPromise> {
const serverDependency = calcServerDependency(serverVersion);
Expand Down Expand Up @@ -53,14 +53,35 @@ export async function fetchMetals({
"-p",
];

const environment = {
env: {
...process.env,
...extraEnv,
},
};

if (coursier.endsWith(".jar")) {
const jarArgs = ["-Dfile.encoding=UTF-8", "-jar", coursier].concat(
coursierArgs
);
return { promise: spawn(javaPath, jarArgs) };
const jarArgs = [
...javaOptions,
...fetchProperties,
"-Dfile.encoding=UTF-8",
"-jar",
coursier,
].concat(coursierArgs);
return { promise: spawn(javaPath, jarArgs, environment) };
} else {
// Convert Java properties to the "-J" argument form used by Coursier
var javaArgs: Array<string> = [];

// setting properties on windows native launcher doesn't work
if (process.platform != "win32")
javaArgs = javaOptions
.concat(["-Dfile.encoding=UTF-8"])
.concat(fetchProperties)
.map((p) => `-J${p}`);

return {
promise: spawn(coursier, coursierArgs),
promise: spawn(coursier, javaArgs.concat(coursierArgs), environment),
};
}
}
Expand Down
Loading