forked from scalameta/metals-vscode
/
getJavaConfig.ts
52 lines (46 loc) · 1.17 KB
/
getJavaConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { getJavaOptions } from "./getJavaOptions";
import * as path from "path";
export interface JavaConfig {
javaOptions: string[];
javaPath: string;
coursier: string;
coursierMirrorFilePath: string | undefined;
extraEnv: {
[k: string]: string | undefined;
};
}
interface GetJavaConfigOptions {
workspaceRoot: string | undefined;
javaHome: string;
coursier: string;
coursierMirrorFilePath: string | undefined;
customRepositories: string[] | undefined;
}
export function getJavaConfig({
workspaceRoot,
javaHome,
coursier,
coursierMirrorFilePath,
customRepositories = [],
}: GetJavaConfigOptions): JavaConfig {
const javaOptions = getJavaOptions(workspaceRoot);
const javaPath = path.join(javaHome, "bin", "java");
const coursierRepositories =
customRepositories.length > 0
? { COURSIER_REPOSITORIES: customRepositories.join("|") }
: {};
const coursierMirrors = coursierMirrorFilePath
? { COURSIER_MIRRORS: coursierMirrorFilePath }
: {};
const extraEnv = {
...coursierRepositories,
...coursierMirrors,
};
return {
javaOptions,
javaPath,
coursier,
coursierMirrorFilePath,
extraEnv,
};
}