Skip to content

[Feature] 构建提供者的服务运行支持按配置类型连接调试(Spring Boot 运行配置可直接点调试) #2107

Closed

Description

@1lck

Problem to solve / 要解决的问题

Maven 插件(Lithe-IDEA/lithe-plugin-maven#28)把 Spring Boot 应用声明成构建提供者的服务运行,并按契约声明了按配置类型连接的调试:run[].debug: {"configurationType": "java"}(契约 v1 README 的“Registry connection debugging”一节,Core fixture build-providers/build-connection-debug-options.json)。提供者已经能处理:收到 launchOptions.debug 的连接目标时,给 JVM 加上挂起等待的 -agentlib:jdwp=…,suspend=y,address=<host>:<port>。Core 也已经支持带 debug 的 launch options。

但 Viva 桌面宿主还没有实现这一段,所以用户在标题栏对 Spring Boot 运行配置点“调试”时,只会收到“不能调试”的提示:

  • pluginservice.parseBuildSystems 只读取 run[].debug.adapter(同包原生调试),忽略 configurationType,所以 titleConfigurationFacts 把这类运行判为不可调试(desktop/internal/pluginservice/builds.go、desktop/internal/workbench/title_run.go);
  • core.RunLaunchOptions 没有 debug 字段,构建提供者运行的准备请求里也不会带调试目标(desktop/internal/core/run_config.go);
  • 宿主现在只为插件函数通过 run/start 启动的运行实现了按配置类型连接调试(desktop/internal/workbench/debug_start.go 的 attachDebugForRun),构建提供者的运行没有走这条路。

影响:Maven(以及以后的 Gradle 等)项目里的 Spring Boot 服务能运行,但不能在 Lithe 里断点调试,只能另建远程调试。

Proposed solution / 建议方案

按契约在宿主实现“构建提供者服务运行的按配置类型连接调试”:

  1. 解析 run[].debug.configurationType,标题栏和运行窗口把这类运行视为可调试。
  2. 调试时,宿主从调试适配器注册表里选一个当前启用、声明了该配置类型并支持 attach 的适配器(遵守用户显式选择;没有或有歧义时在启动提供者进程前失败并说明原因),分配本机端口,在 lithe/build/prepareRun 的 launchOptions 里带上 {"debug":{"adapterID","configurationType","target":{"kind":"connection","host":"127.0.0.1","port":…}}}。
  3. 宿主启动提供者返回的进程,等端口就绪后用选中的适配器 attach,复用 attachDebugForRun 已有的就绪等待、会话管理和清理;适配器被禁用或替换、运行停止时撤销并清理进程。
  4. 补宿主端到端测试:用 Maven 插件和 Java Support 插件的发布包调试一个 Spring Boot 应用,断点命中后停止,进程和端口都释放。

验收:在 Spring Boot 项目里对运行配置点“调试”,服务在启动处挂起,Java 调试器连上后继续启动,断点命中;停止后进程退出、端口释放。macOS 和 Windows 行为一致。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Debug / 调试

Priority / 优先级

P1 / 尽快处理:使用体验大幅下降,但通常仍可继续使用

Alternatives considered / 已考虑的替代方案

  • 在运行配置的 JVM 参数里手动加 -agentlib:jdwp=…,再用调试窗口的远程连接附加。能用,但每次都要手动改参数和连接。
  • 让 Maven 插件声明同包原生调试(debug.adapter):契约规定原生调试只适用于原生可执行文件的 launch,不适用于 JVM 服务。
  • IDEA:对 Spring Boot 运行配置直接点调试,由 IDE 加调试参数并附加。

Additional context / 补充信息

Checklist / 提交前检查

  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:debugenhancementplatform:cross-platformreview: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions