diff --git a/README.md b/README.md index dfed576..a7428b5 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ A lightweight Java Debugger based on [Java Debug Server](https://github.com/Micr ## Requirements - JDK (version 1.8.0 or later) - VS Code (version 1.17.0 or later) -- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.12.0 or later) +- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.13.0 or later) ## Install diff --git a/src/commands.ts b/src/commands.ts index ee7c0d7..44f6aff 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -13,7 +13,7 @@ export const JAVA_RESOLVE_CLASSPATH = "vscode.java.resolveClasspath"; export const JAVA_RESOLVE_MAINCLASS = "vscode.java.resolveMainClass"; -export const JAVA_BUILD_WORKSPACE = "vscode.java.buildWorkspace"; +export const JAVA_BUILD_WORKSPACE = "java.workspace.compile"; export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand"; diff --git a/src/configurationProvider.ts b/src/configurationProvider.ts index a8af641..b31c93f 100644 --- a/src/configurationProvider.ts +++ b/src/configurationProvider.ts @@ -79,10 +79,23 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration // log a warning message and continue, since logger failure should not block debug session console.log("Cannot set log level to java debuggeer.") } - if (Object.keys(config).length === 0) { // No launch.json in current workspace. - // VSCode will create a launch.json automatically if no launch.json yet. + + // trigger build workspace + try { + const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE); + console.log(buildResult); + } catch (err) { + vscode.window.showErrorMessage("Build failed, please fix build error first."); return config; - } else if (config.request === "launch") { + } + + if (Object.keys(config).length === 0) { // No launch.json in current workspace. + // Generate config in memory for files without project. + config.type = "java"; + config.name = "Java Debug"; + config.request = "launch"; + } + if (config.request === "launch") { if (!config.mainClass) { const res = (await resolveMainClass()); if (res.length === 0) {