From 343a6b7d62945c5b44571fb653a68f34616095a3 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Mon, 29 Apr 2024 16:55:50 +0800 Subject: [PATCH 01/12] merge --- extension/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extension/package-lock.json b/extension/package-lock.json index 6c2277ddc..dfa036b18 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -4275,9 +4275,9 @@ "dev": true }, "node_modules/protobufjs": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.4.tgz", - "integrity": "sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ==", + "version": "7.2.6", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.6.tgz", + "integrity": "sha512-dgJaEDDL6x8ASUZ1YqWciTRrdOuYNzoOf27oHNfdyvKqHr5i0FV7FSLU+aIeFjyFgVxrpTOtQUi0BLLBymZaBw==", "dev": true, "hasInstallScript": true, "dependencies": { From 40dcb5f4e91e0dfdb9178c1bfbc6d8904a09616b Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 16:53:47 +0800 Subject: [PATCH 02/12] add debug build server config --- .vscode/launch.json | 25 ++++++++++++++-- .../gradle/bs/importer/ImporterPlugin.java | 30 ++++++++++++------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5101fbb89..93799c23c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,7 +18,7 @@ "order": 1 }, "env": { - "DEBUG_VSCODE_JAVA":"true" + "DEBUG_VSCODE_JAVA":"true", }, }, { @@ -74,13 +74,34 @@ ], "preLaunchTask": "Gradle: Build", "env": { - "VSCODE_DEBUG_PLUGIN": "true" + "VSCODE_DEBUG_PLUGIN": "true", }, "presentation": { "group": "debug", "order": 2 } }, + { + "name": "Debug Extension & Build Server", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/extension" + ], + "outFiles": [ + "${workspaceFolder}/extension/dist/**/*.js" + ], + "preLaunchTask": "Gradle: Build", + "presentation": { + "group": "debug", + "order": 3 + }, + "env": { + "DEBUG_VSCODE_JAVA":"true", + "DEBUG_VSCODE_BUILD_SERVER":"true" + }, + }, { "name": "Debug Language Server: Launch Extension", "type": "extensionHost", diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java index c6d915185..c068d52db 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java @@ -3,6 +3,8 @@ import java.io.File; import java.io.IOException; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -84,16 +86,24 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr String pluginPath = getBuildServerPluginPath(); - ProcessBuilder build = new ProcessBuilder( - javaExecutablePath, - "--add-opens=java.base/java.lang=ALL-UNNAMED", - "--add-opens=java.base/java.io=ALL-UNNAMED", - "--add-opens=java.base/java.util=ALL-UNNAMED", - "-Dplugin.dir=" + pluginPath, - "-cp", - String.join(getClasspathSeparator(), classpaths), - "com.microsoft.java.bs.core.Launcher" - ); + List command = new ArrayList<>(); + // Check for the DEBUG_VSCODE_SERVER environment variable + String debugServer = System.getenv("DEBUG_VSCODE_BUILD_SERVER"); + + command.add(javaExecutablePath); + if ("true".equals(debugServer)) { + command.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8989"); + } + command.add("--add-opens=java.base/java.lang=ALL-UNNAMED"); + command.add("--add-opens=java.base/java.io=ALL-UNNAMED"); + command.add("--add-opens=java.base/java.util=ALL-UNNAMED"); + command.add("-Dplugin.dir=" + pluginPath); + command.add("-cp"); + command.add(String.join(getClasspathSeparator(), classpaths)); + command.add("com.microsoft.java.bs.core.Launcher"); + + + ProcessBuilder build = new ProcessBuilder(command); try { Process process = build.start(); From a11f9e23fa25f80fa2d52ce325fce0bf382f1581 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 17:03:26 +0800 Subject: [PATCH 03/12] add debug build server config --- .vscode/launch.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 93799c23c..56bf18e66 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -98,7 +98,6 @@ "order": 3 }, "env": { - "DEBUG_VSCODE_JAVA":"true", "DEBUG_VSCODE_BUILD_SERVER":"true" }, }, From e52405c7fd1069c4598bc04fcfbc5b55ca6446dd Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 18:54:55 +0800 Subject: [PATCH 04/12] add build server debug document --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed0a5b509..cd7c8bdda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,31 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get 1. Run vscode launch configuration `Debug Extension & Gradle Plugin`. 2. Run vscode launch configuration `Attach to Gradle Plugin`. +## Debugging Gradle Build Server + +To debug the Extension with the [Gradle Build Server](https://github.com/microsoft/build-server-for-gradle), follow these steps: + +1. Open the `extension/build-server-for-gradle` directory, which you should have imported previously as a separate project. + +2. In the `.vscode/launch.json` of the build-server-for-gradle project, ensure you have the following configuration to attach the debugger: + + ```json + { + "type": "java", + "name": "Attach to Gradle Build Server", + "request": "attach", + "hostName": "localhost", + "port": "8989", + "projectName": "server" + } + ``` + +3. In your main project (vscode-gradle), start the `Debug Extension & Build Server` launch configuration. + +4. In the `build-server-for-gradle` project, start the `Attach to Gradle Build Server` launch configuration. + + + > Note: There is a known issue that when the Gradle project stores in a sub-folder of the root folder, the `Attach to Gradle Plugin` will fail to attach. See [#1237](https://github.com/microsoft/vscode-gradle/issues/1237). ## Debugging Gradle Language Server (editing feature related) From 6945103ad0781ffefd99a6d1c3f88dc103df847a Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 19:02:48 +0800 Subject: [PATCH 05/12] add build server debug document --- CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd7c8bdda..63d172021 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,6 +38,8 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get 1. Run vscode launch configuration `Debug Extension & Gradle Plugin`. 2. Run vscode launch configuration `Attach to Gradle Plugin`. +> Note: There is a known issue that when the Gradle project stores in a sub-folder of the root folder, the `Attach to Gradle Plugin` will fail to attach. See [#1237](https://github.com/microsoft/vscode-gradle/issues/1237). + ## Debugging Gradle Build Server To debug the Extension with the [Gradle Build Server](https://github.com/microsoft/build-server-for-gradle), follow these steps: @@ -63,7 +65,6 @@ To debug the Extension with the [Gradle Build Server](https://github.com/microso -> Note: There is a known issue that when the Gradle project stores in a sub-folder of the root folder, the `Attach to Gradle Plugin` will fail to attach. See [#1237](https://github.com/microsoft/vscode-gradle/issues/1237). ## Debugging Gradle Language Server (editing feature related) From 9bb6ce4258fc2bfc6900a2d7e2498264fa680446 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 19:08:49 +0800 Subject: [PATCH 06/12] add build server debug document --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 63d172021..67afa9fb5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get To debug the Extension with the [Gradle Build Server](https://github.com/microsoft/build-server-for-gradle), follow these steps: -1. Open the `extension/build-server-for-gradle` directory, which you should have imported previously as a separate project. +1. Open the `extension/build-server-for-gradle` directory, which you should have [imported previously](#build-gradle-project-importer) as a separate project. 2. In the `.vscode/launch.json` of the build-server-for-gradle project, ensure you have the following configuration to attach the debugger: @@ -61,7 +61,7 @@ To debug the Extension with the [Gradle Build Server](https://github.com/microso 3. In your main project (vscode-gradle), start the `Debug Extension & Build Server` launch configuration. -4. In the `build-server-for-gradle` project, start the `Attach to Gradle Build Server` launch configuration. +4. In the build-server-for-gradle project, start the `Attach to Gradle Build Server` launch configuration. From af31a2d28ca7f47426598d165e00d01c3d5cfd75 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 19:19:09 +0800 Subject: [PATCH 07/12] add build server debug config --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 56bf18e66..09d2812aa 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,7 +18,7 @@ "order": 1 }, "env": { - "DEBUG_VSCODE_JAVA":"true", + "DEBUG_VSCODE_JAVA":"true" }, }, { @@ -74,7 +74,7 @@ ], "preLaunchTask": "Gradle: Build", "env": { - "VSCODE_DEBUG_PLUGIN": "true", + "VSCODE_DEBUG_PLUGIN": "true" }, "presentation": { "group": "debug", From d292ae205ef746df1470ef5016f8ffba7704add8 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Wed, 8 May 2024 19:22:59 +0800 Subject: [PATCH 08/12] add build server debug config --- .../src/com/microsoft/gradle/bs/importer/ImporterPlugin.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java index c068d52db..20aeea72d 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java @@ -86,9 +86,8 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr String pluginPath = getBuildServerPluginPath(); - List command = new ArrayList<>(); - // Check for the DEBUG_VSCODE_SERVER environment variable String debugServer = System.getenv("DEBUG_VSCODE_BUILD_SERVER"); + List command = new ArrayList<>(); command.add(javaExecutablePath); if ("true".equals(debugServer)) { From 376bf908c2d13fdb6f30471fb5f9992ca4057933 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Thu, 9 May 2024 10:25:28 +0800 Subject: [PATCH 09/12] update build server debug config --- .vscode/launch.json | 2 +- CONTRIBUTING.md | 5 ----- .../src/com/microsoft/gradle/bs/importer/ImporterPlugin.java | 4 ++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 09d2812aa..3c3f33f82 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -98,7 +98,7 @@ "order": 3 }, "env": { - "DEBUG_VSCODE_BUILD_SERVER":"true" + "DEBUG_GRADLE_BUILD_SERVER":"true" }, }, { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67afa9fb5..6bf754ed4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,6 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get To debug the Extension with the [Gradle Build Server](https://github.com/microsoft/build-server-for-gradle), follow these steps: 1. Open the `extension/build-server-for-gradle` directory, which you should have [imported previously](#build-gradle-project-importer) as a separate project. - 2. In the `.vscode/launch.json` of the build-server-for-gradle project, ensure you have the following configuration to attach the debugger: ```json @@ -60,12 +59,8 @@ To debug the Extension with the [Gradle Build Server](https://github.com/microso ``` 3. In your main project (vscode-gradle), start the `Debug Extension & Build Server` launch configuration. - 4. In the build-server-for-gradle project, start the `Attach to Gradle Build Server` launch configuration. - - - ## Debugging Gradle Language Server (editing feature related) 1. Run vscode launch configuration `Debug Language Server: Launch Extension`. diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java index 20aeea72d..91f0dec05 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java @@ -86,11 +86,11 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr String pluginPath = getBuildServerPluginPath(); - String debugServer = System.getenv("DEBUG_VSCODE_BUILD_SERVER"); + List command = new ArrayList<>(); command.add(javaExecutablePath); - if ("true".equals(debugServer)) { + if (Boolean.parseBoolean(System.getenv("DEBUG_GRADLE_BUILD_SERVER"))) { command.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8989"); } command.add("--add-opens=java.base/java.lang=ALL-UNNAMED"); From 073af9f6578c1ac278eff77bd0eb719eb9fe93a0 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Thu, 9 May 2024 10:28:02 +0800 Subject: [PATCH 10/12] update build server debug config --- CONTRIBUTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bf754ed4..3ade961ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,6 @@ To debug the Extension with the [Gradle Build Server](https://github.com/microso 1. Open the `extension/build-server-for-gradle` directory, which you should have [imported previously](#build-gradle-project-importer) as a separate project. 2. In the `.vscode/launch.json` of the build-server-for-gradle project, ensure you have the following configuration to attach the debugger: - ```json { "type": "java", @@ -57,7 +56,6 @@ To debug the Extension with the [Gradle Build Server](https://github.com/microso "projectName": "server" } ``` - 3. In your main project (vscode-gradle), start the `Debug Extension & Build Server` launch configuration. 4. In the build-server-for-gradle project, start the `Attach to Gradle Build Server` launch configuration. From 0f1f1393a940b02d544b460bb9c85a3254a53cf5 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Thu, 9 May 2024 12:00:03 +0800 Subject: [PATCH 11/12] add build server debug config --- .../src/com/microsoft/gradle/bs/importer/ImporterPlugin.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java index 91f0dec05..2914cd666 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java @@ -86,7 +86,6 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr String pluginPath = getBuildServerPluginPath(); - List command = new ArrayList<>(); command.add(javaExecutablePath); @@ -101,7 +100,6 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr command.add(String.join(getClasspathSeparator(), classpaths)); command.add("com.microsoft.java.bs.core.Launcher"); - ProcessBuilder build = new ProcessBuilder(command); try { From d790dd056e40aa3c33faea60ff620cda40bfdac4 Mon Sep 17 00:00:00 2001 From: Jiaaming <2455951489@qq.com> Date: Thu, 9 May 2024 12:20:20 +0800 Subject: [PATCH 12/12] add build server debug config --- .../src/com/microsoft/gradle/bs/importer/ImporterPlugin.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java index 2914cd666..81a4264d4 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/ImporterPlugin.java @@ -87,7 +87,6 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr String pluginPath = getBuildServerPluginPath(); List command = new ArrayList<>(); - command.add(javaExecutablePath); if (Boolean.parseBoolean(System.getenv("DEBUG_GRADLE_BUILD_SERVER"))) { command.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8989"); @@ -101,7 +100,6 @@ public static BuildServerConnection getBuildServerConnection(IPath rootPath) thr command.add("com.microsoft.java.bs.core.Launcher"); ProcessBuilder build = new ProcessBuilder(command); - try { Process process = build.start(); BuildClient client = new GradleBuildClient();