From 80490fa1500a3725a5c6e29ca580a8eaf475f877 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Wed, 1 Nov 2017 09:45:25 +0800 Subject: [PATCH] Customize launching connector to support cwd and enviroment variable (#119) * Customize launching connector to support cwd and enviroment variable Signed-off-by: Jinbo Wang * disable tslint rule for 'Interpolation will only work for template strings' error Signed-off-by: Jinbo Wang --- README.md | 2 ++ package.json | 11 +++++++++++ src/configurationProvider.ts | 2 ++ 3 files changed, 15 insertions(+) diff --git a/README.md b/README.md index e16d894..1d45104 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht - `encoding` - The `file.encoding` setting for the JVM. If not specified, 'UTF-8' will be used. Possible values can be found in http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html. - `vmArgs` - The extra options and system properties for the JVM (e.g. -Xms\ -Xmx\ -D\=\). - `projectName` - The preferred project in which the debugger searches for classes. There could be duplicated class names in different projects. This setting also works when the debugger looks for the specified main class when launching a program. +- `cwd` - The working directory of the program. +- `env` - The extra environment variables for the program. ### Attach diff --git a/package.json b/package.json index e654371..c7d0287 100644 --- a/package.json +++ b/package.json @@ -93,6 +93,16 @@ "type": "string", "description": "The file.encoding setting for the JVM. If not specified, 'UTF-8' will be used. Possible values can be found in http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html.", "default": "UTF-8" + }, + "cwd": { + "type": "string", + "description": "The working directory of the program.", + "default": "${workspaceFolder}" + }, + "env": { + "type": "object", + "description": "The extra environment variables for the program.", + "default": {} } } }, @@ -140,6 +150,7 @@ "type": "java", "name": "Debug (Launch)", "request": "launch", + "cwd": "^\"\\${workspaceFolder}\"", "mainClass": "", "args": "" } diff --git a/src/configurationProvider.ts b/src/configurationProvider.ts index bde8774..f99eaf2 100644 --- a/src/configurationProvider.ts +++ b/src/configurationProvider.ts @@ -33,6 +33,8 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration type: "java", name: this.constructLaunchConfigName(item.mainClass, item.projectName, cache), request: "launch", + // tslint:disable-next-line + cwd: "${workspaceFolder}", mainClass: item.mainClass, projectName: item.projectName, args: "",