Skip to content

[Bug] Maven 多模块 Run/Debug 未带 -am,本地模块被当成远程依赖导致启动失败 #461

Description

@1lck

Platform / 平台

  • macOS
  • Windows

(两端共用 lithe-core 的 launch plan;不是 Windows 独有。当前复现报告来自 Windows,macOS 在相同条件下预期一致。)

Area / 模块

  • Maven
  • Run / 运行
  • Debug / 调试

Lithe version / Lithe 版本

  • Windows 复现:0.4.1(session a10be7eb,日志 lithe.2026-09-04T12-06-36.810+0800.a10be7eb.001.log
  • 行为依据:当前 lithe-core 契约与实现(见下方 Root cause)

Priority / 优先级

P1 / 尽快处理:多模块 Spring Boot 工程首次点 Run 常直接失败,核心启动流程受阻;可用 mvn install 或手动加 -am 绕过,但用户不易理解。

OS and architecture / 操作系统与架构

  • 复现环境:Windows(用户会话日志)
  • 预期影响:macOS / Windows 相同逻辑

Environment / 环境信息

  • 工程类型:Maven 多模块 Spring Boot(示例:dms-api
  • 可运行模块:dms-controller(含 @SpringBootApplication / spring-boot-maven-plugin
  • 同 reactor 本地依赖模块:dms-module-captchacom.dms:dms-module-captcha:1.0.0)等
  • 远程仓库:阿里云 Central mirror(错误信息指向 maven.aliyun.com
  • 前置条件:本机 ~/.m2(或等价本地仓库)尚未 install 过上述内部模块

Summary / 问题摘要

对多模块工程中的 Spring Boot 模块执行 Run / Debug 时,Lithe 生成的 Maven 命令形如:

mvn -B -ntp -pl dms-controller \
  -Dspring-boot.run.main-class=... \
  spring-boot:run

只有 -pl <module>没有 -am(also-make)。

因此:

  1. Maven 不会在本次 reactor 中先构建被依赖的本地模块(如 dms-module-captcha);
  2. 转而按 GAV 坐标去本地仓库 / 远程仓库解析;
  3. 内部模块不在远程仓 → 报 Could not resolve dependencies / was not found in ...
  4. 用户观感像是「把我的模块当成了第三方依赖」。

这与「模块没被项目树识别」无关:JDT/Maven import 可以正常看到多模块(日志中有 Importing Maven project(s)projectCount=8、打开 dms-module-param 等),失败发生在 Run 启动计划参数

Steps to reproduce / 复现步骤

  1. 打开一个 Maven 多模块工程(父 POM 声明 modules;子模块 A 依赖同 reactor 子模块 B)。
  2. 确保本机本地仓库中 没有 预先 install 过模块 B(干净环境或新 clone 后首次启动最易复现)。
  3. 不要先在根目录执行 mvn install
  4. 在 Lithe 中对可运行模块 A(例如带 spring-boot-maven-plugindms-controller)直接 Run
  5. 观察 Run 面板中的 Maven 命令与 BUILD FAILURE。

Expected behavior / 预期行为

  • 首次 Run 多模块可运行服务时,应能解析并构建同 reactor 的模块间依赖,或给出明确、可操作的提示(例如需先 install / 将自动 also-make)。
  • 更接近常见 IDE 体验:启动可运行模块时,依赖的本地模块一并参与构建,而不是去中央仓库下载内部 artifact。
  • 可选产品方向(待定):
    • Run/Debug 对 reactor 内模块默认加 -am;或
    • 仅在依赖未安装到本地仓库时加 -am / 先 ensure-install;或
    • 保持现状但在失败时识别「同 reactor 模块未构建」并给出一键修复。

Actual behavior / 实际行为

  • 命令仅 -pl <runnable-module>,无 -am
  • 构建失败,典型错误:
[WARNING] The POM for com.dms:dms-module-captcha:jar:1.0.0 is missing, no dependency information available
[ERROR] Failed to execute goal ... Could not resolve dependencies for project com.dms:dms-controller:jar:1.0.0:
com.dms:dms-module-captcha:jar:1.0.0 was not found in http://maven.aliyun.com/nexus/content/repositories/central/
  • 用户误以为内部模块被当成第三方库。

Root cause(代码 / 契约,便于后续修复)

有意区分两套入口(跨平台):

入口 -pl -am
Maven 工具窗口 maven.launchPlan
Run / Debug runConfig.createLaunchPlan

依据:

  • shared/contracts/rust-core-api.md:Module plans from maven.launchPlan use -pl <module> -am;Run and Debug plans use -pl <module> without -am
  • shared/contracts/application-boundary.md:Tool-window module launches add -am;Run and Debug retain -pl without implicitly building dependencies。
  • 实现:rust/lithe-core/src/project/maven.rsalso_make 参数);Run 配置相关测试断言 arguments 不含 -am(如 rust/lithe-core/src/tests/run_configuration.rs)。

因此这是 当前设计行为 + 差的首次启动体验,不是单一平台 bug;修复需同步契约、Core、双端与测试。

Workaround / 当前绕过方式

reactor 根目录(父 pom.xml)任选其一:

# 1) 先安装全部模块到本地仓库,再在 Lithe 里点 Run
mvn -B -ntp install -DskipTests

# 2) 命令行直接带依赖启动
mvn -B -ntp -pl dms-controller -am spring-boot:run

# 3) 或在 Lithe Maven 工具窗口对相关模块执行 install/build(该入口会带 -am),再 Run

Logs or diagnostic output / 日志或诊断输出

Run 面板(截图时间约 12:14:32,与失败直接相关)

$ mvn ... -B -ntp -pl dms-controller -Dspring-boot.run.main-class=com.dms.controller.DmsApplication spring-boot:run
...
[WARNING] The POM for com.dms:dms-module-captcha:jar:1.0.0 is missing, no dependency information available
[INFO] BUILD FAILURE
[ERROR] ... com.dms:dms-module-captcha:jar:1.0.0 was not found in http://maven.aliyun.com/...

Session 日志(lithe.2026-09-04T12-06-36...001.log)说明

  • 有价值但 未记录 上述 Run/Maven 失败本身(Run 进程输出似乎未写入 session log,仅在 Run 面板)。
  • 可佐证:工程/JDT 已识别多模块(Importing Maven project(s)Applying Maven profiles ... projectCount=8),故问题不在「没扫到模块」。
  • 同会话另有一条 独立 问题(勿与本 issue 混为一谈,可另开):
javaWorkspaceChanges:failed
error="Java workspace paths must be workspace-relative."
error_code=invalid_request
  • 另:Run 启动命令行 / exit code / 关键 ERROR 摘要若能进入 session log,会显著降低此类问题的排查成本(可作为附带改进)。

Screenshots or recordings / 截图或录屏

用户提供的 IDE 截图:左侧高亮 dms-module-captcha,右侧 Run 失败且错误框选「本地模块坐标在远程仓 not found」。

Checklist

  • 已搜索现有 Issue;本条用于记录该多模块 Run 场景与契约背景。
  • 已去除敏感路径与个人数据(日志中路径保持 redacted 表述)。

Suggested follow-ups / 建议跟进(非本 issue 必须范围)

  1. 产品决策:Run/Debug 是否默认 -am,或仅在缺失 reactor 依赖时 also-make / pre-install。
  2. 同步更新契约、maven_arguments / launch plan、双端测试与 fixtures。
  3. (可选)失败诊断:识别「依赖 artifact 属于当前 reactor 但未构建」并提示绕过命令。
  4. (可选,另 issue)session log 记录 Run 启动命令与失败摘要;Windows javaWorkspaceChanges workspace-relative 路径错误。

Activity

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

    P1尽快处理:使用体验大幅下降,但通常仍可继续使用Rust Coresomething should change the rust corebugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions