Skip to content

Commit

Permalink
Merge pull request #1510 from tgodzik/fix-encoding
Browse files Browse the repository at this point in the history
bugfix: Add back properties and env when fetching metals
  • Loading branch information
tgodzik authored May 24, 2024
2 parents 9eb637f + 98df585 commit 87a0b50
Showing 1 changed file with 27 additions and 6 deletions.
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

0 comments on commit 87a0b50

Please sign in to comment.