diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..0b23a411 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.ts] +[*.js] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false \ No newline at end of file diff --git a/src/javaServerStarter.ts b/src/javaServerStarter.ts index eb1ca67f..150a8529 100644 --- a/src/javaServerStarter.ts +++ b/src/javaServerStarter.ts @@ -16,8 +16,23 @@ export function prepareExecutable(requirements: RequirementsData, xmlJavaExtensi options.env = process.env; options.stdio = 'pipe'; executable.options = options; - executable.command = path.resolve(requirements.java_home + '/bin/java'); - executable.args = prepareParams(requirements, xmlJavaExtensions, context); + const useBinary = getXMLConfiguration().get("server.binary.enabled", false); + if (useBinary) { + //TODO handle case when other extensions contributing jars expect to force JVM mode + const binaryPath = findServerBinary(); + if (binaryPath) { + executable.command = binaryPath; + } else { + //TODO handle missing binary + console.log("Missing xml.server.binary.path"); + } + //TODO handle binary args + } + // Fall back to JVM Mode + if(!(executable.command)) { + executable.command = path.resolve(requirements.java_home + '/bin/java'); + executable.args = prepareParams(requirements, xmlJavaExtensions, context); + } return executable; } @@ -78,6 +93,21 @@ function prepareParams(requirements: RequirementsData, xmlJavaExtensions: string return params; } +function findServerBinary(): string { + const config = getXMLConfiguration(); + let binaryPath:string = config.get("server.binary.path"); + if (!binaryPath) { + let server_home: string = path.resolve(__dirname, '../server'); + let binariesFound: Array = glob.sync('**/lemminx*', { cwd: server_home }); + if (binariesFound.length) { + binaryPath = path.resolve(server_home, binariesFound[0]); + } + //TODO handle missing binary + } + return (binaryPath)?binaryPath: null; +} + + function startedInDebugMode(): boolean { const args = (process as any).execArgv as string[]; return hasDebugFlag(args); diff --git a/src/requirements.ts b/src/requirements.ts index 04069a33..50076710 100644 --- a/src/requirements.ts +++ b/src/requirements.ts @@ -30,6 +30,7 @@ interface ErrorData { * */ export async function resolveRequirements(context: ExtensionContext): Promise { + //TODO Handle different requirements if using binary const javaHome = await checkJavaRuntime(context); const javaVersion = await checkJavaVersion(javaHome); return Promise.resolve({ 'java_home': javaHome, 'java_version': javaVersion});