chores: Add build server debug config (#1486)

This commit is contained in:
Jiaming 2024-05-10 08:56:59 +08:00 коммит произвёл GitHub
Родитель bfb2eacff0
Коммит fcbabebe55
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 54 добавлений и 10 удалений

20
.vscode/launch.json поставляемый
Просмотреть файл

@ -81,6 +81,26 @@
"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_GRADLE_BUILD_SERVER":"true"
},
},
{
"name": "Debug Language Server: Launch Extension",
"type": "extensionHost",

Просмотреть файл

@ -40,6 +40,25 @@ The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get
> 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:
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",
"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.
## Debugging Gradle Language Server (editing feature related)
1. Run vscode launch configuration `Debug Language Server: Launch Extension`.

Просмотреть файл

@ -3,6 +3,8 @@ package com.microsoft.gradle.bs.importer;
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,17 +86,20 @@ public class ImporterPlugin extends Plugin {
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<String> 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");
}
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();
BuildClient client = new GradleBuildClient();