VSCode debug gradle multiple-project 项目
项目分层(阿里巴巴Java开发手册推荐)
Gradle项目
在APP project的build.gradle中配置依赖其他project,执行task会输出到build文件夹
默认debug的时候会创建launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Java Program",
"request": "launch",
"mainClass": "com.xxx.yyy.app"
}
]
}
launch debug
- 运行gradle task
这个手动步骤可以创建一个task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "gradle",
"id": "",
"script": "app:dev",
"description": "Runs this project as a Spring Boot application.",
"group": "application",
"project": "app",
"buildFile": "",
"rootProject": "",
"projectFolder": "",
"workspaceFolder": "",
"args": "",
"javaDebug": false,
"problemMatcher": [
"$gradle"
],
"label": "build"
}
]
}
- launch.json修改为
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Java Program",
"request": "launch",
"mainClass": "com.xxx.yyy.app",
"classPaths": [
"$Auto",
"BUILD_PATH"
],
"preLaunchTask": "build"
}
]
}
attach debug
task.json
{
"version": "2.0.0",
"tasks": [
{
"type": "gradle",
"id": "",
"script": "app:bootRun",
"description": "Runs this project as a Spring Boot application.",
"group": "application",
"project": "app",
"buildFile": "",
"rootProject": "",
"projectFolder": "",
"workspaceFolder": "",
"args": "",
"javaDebug": true,
"problemMatcher": [
"$gradle"
],
"label": "build"
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Java Program",
"request": "attach",
"hostName": "localhost",
"port": "5005",
"preLaunchTask": "gradle: app:bootRun",
"sourcePaths": ["BUILD_PATH"]
}
]
}