chore: Add debug plugin config (#1220)

This commit is contained in:
Shi Chen 2022-06-24 11:20:15 +08:00 коммит произвёл GitHub
Родитель 0ae6cd8291
Коммит 53174f5dee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 34 добавлений и 9 удалений

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

@ -49,6 +49,26 @@
"hidden": true
}
},
{
"name": "Debug Extension & Gradle Plugin",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/extension"
],
"outFiles": [
"${workspaceFolder}/extension/dist/**/*.js"
],
"preLaunchTask": "Gradle: Build",
"env": {
"VSCODE_DEBUG_PLUGIN": "true"
},
"presentation": {
"group": "debug",
"order": 2
}
},
{
"name": "Debug Language Server: Launch Extension",
"type": "extensionHost",
@ -86,7 +106,7 @@
},
{
"type": "java",
"name": "Debug Gradle Plugin",
"name": "Attach to Gradle Plugin",
"request": "attach",
"hostName": "localhost",
"projectName": "gradle-plugin",

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

@ -11,15 +11,8 @@
},
"args": [
"build",
"extension:buildDev",
"-x",
"extension:buildProd",
"-x",
"test",
"-x",
"npm-package:build",
"-x",
"extension:buildTest"
],
"presentation": {
"reveal": "always"

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

@ -17,6 +17,13 @@ Start by opening an issue using one of the issue templates, or propose a change
Running the build for the first time can take a bit of time, but subsequent builds should be fast.
## Debugging Gradle plugin
The extension uses a Gradle plugin (`com.microsoft.gradle.GradlePlugin`) to get a lot of information from your project's Gradle build. If you want to debug the Gradle plugin, you can follow these steps:
1. Run vscode launch configuration `Debug Extension & Gradle Plugin`
2. Run vscode launch configuration `Attach to Gradle Plugin`
## Development Workflow
Open the root of the project in VS Code.

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

@ -102,7 +102,12 @@ public class GetBuildHandler {
return;
}
File initScript = PluginUtils.createInitScript();
List<String> arguments = Arrays.asList("--init-script", initScript.getAbsolutePath());
List<String> arguments = new ArrayList<>();
String debugPlugin = System.getenv("VSCODE_DEBUG_PLUGIN");
if ("true".equals(debugPlugin)) {
arguments.add("-Dorg.gradle.debug=true");
}
arguments.addAll(Arrays.asList("--init-script", initScript.getAbsolutePath()));
String jvmArguments = req.getGradleConfig().getJvmArguments();
if (!Strings.isNullOrEmpty(jvmArguments)) {
arguments.addAll(Arrays.stream(jvmArguments.split(" ")).filter(e -> e != null && !e.isEmpty())