Skip to content

feat(maven): unify shared Maven context and macOS tool window - #320

Merged
1lck merged 3 commits into
previewfrom
feat/issue-291-macos-maven
Aug 29, 2026
Merged

feat(maven): unify shared Maven context and macOS tool window#320
1lck merged 3 commits into
previewfrom
feat/issue-291-macos-maven

Conversation

@Mucheen

@MucheenMucheen commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

关联 Issue

Part of #291.

本 PR 提交共享 Maven Core、版本化契约与 macOS 实现。Windows 实现位于后续 PR #321,避免把两个平台的 UI 和原生适配混在同一个 review 中。

主要变更

  • rust/lithe-core 中统一 Maven reactor/模块/Profile 扫描、配置合并、指纹与 Launch Plan 生成。
  • 将持久化配置与 Launch Context 拆成 maven-portable-configuration-v1maven-launch-context-v1 两份 schema,并增加逐字段契约验证。
  • macOS Maven 工具窗口支持递归模块、Profiles、Lifecycle、自定义 Goal、Skip Tests、停止、折叠、Reload 和 Maven Settings。
  • Maven Settings 支持外部 settings.xml、Maven Home/可执行文件和 Maven 专用 JDK;绝对路径只保存在本机 Application Support。
  • Run、Debug、Maven 工具窗口和 JDT LS 消费同一个 Maven 上下文;Swift 不拼接 Maven 参数。

Review 修复

  • Run 配置显式 cwd 继续拥有最高优先级,未配置时才继承 reactor 工作目录。
  • 新增可选 mavenSkipTestsnull 继承项目设置,显式 false 即使项目勾选 Skip Tests 也会运行测试。
  • Run/Debug 模块启动保持 -pl <module>;只有 Maven 工具窗口默认追加 -am
  • macOS 实际比较 configurationFingerprint,配置变化时触发 JDT reload 提示。
  • 修正 JDT 日志中的 projectCount 和 Maven Home 解析为重复 bin/mvn 的问题。
  • 新增共享 lifecycle/storage identity fixture;macOS 与 Windows 分别验证各自的平台规范化规则。
  • run-configuration-v1 schema 已声明可选 mavenSkipTests

安全与边界

  • Core 只接收 settings.xml 路径,不读取、复制或序列化其中的凭据。
  • Build Output 隐藏本机 settings.xml 绝对路径。
  • 项目配置不保存工作区外的本机绝对路径;自定义 Goal 以结构化 argv 执行,不经过 shell。

验证

  • Rust Core:272 个单元测试、5 个集成测试通过。
  • ./scripts/verify-rust-core.sh
  • ./scripts/verify-shared-contracts.sh
  • ./scripts/verify-service-boundaries.sh
  • ./scripts/verify-module-boundaries.sh
  • ./scripts/verify-rust-core-comments.sh
  • ./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh
  • swift build --target Lithe
  • macOS 真实 UI:带参数 Goal、停止后 Cancelled、子进程清理均已验证。

当前环境限制

本机只有 Command Line Tools,Swift 测试 target 报 no such module 'Testing',因此本地 Swift timing lane 未执行;完整 Xcode 环境由当前 PR CI 验证。

@Mucheen

Copy link
Copy Markdown
CollaboratorAuthor

Windows 平台实现已拆分到 #321#321 只包含 windows/,并以本 PR 提供的共享 Maven Core/contracts 为前置依赖。

@MucheenMucheen added macos something related to macos strongly enhancement New feature or request labels Aug 29, 2026
@Mucheen
Mucheenforce-pushed the feat/issue-291-macos-maven branch from 3543540 to 18db4c9CompareAugust 29, 2026 09:49

@1lck1lck left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

整体质量不错:分层严格按仓库规矩走,Swift 侧确实一处都没有拼 Maven 参数,全部收到 Rust 一处生成,这是最该做对的地方。JDT LS 那段也扎实——pending 有超时、有错误分支、重复 ServiceReady 不会重复入队,测试真覆盖到了。.mvn/maven.config 不漏进 arguments 那个断言写得挺细。

不过结合 #321 一起看,Run 路径上有三个回归,希望合并前处理掉。下面逐条在代码里标了。

另外两件不好挂行号的:

1. 新增的 500 行 Swift 测试一个用例都没跑起来。ExecutionModuleTests +262、MavenRuntimeTests +186、RunConfigurationIntegrationTests +52,报 no such module 'Testing',runner 1.7 秒内失败、0 个用例。这个是前提——不解决的话上面那几个回归的修复也没法验证。通常是切到完整 Xcode toolchain 而不是 Command Line Tools。

2. Lifecycle 阶段列表硬编码了两份。MavenContracts.swift:84 的 enum,和 #321maven.types.ts 里的 MAVEN_LIFECYCLE_PHASES,Rust 里反而没有。clean/validate/…/deploy 这九个词加一个就要改两个文件,而且不会有任何东西告诉你漏了。最轻的做法是放进 shared fixture,两端各加个一致性测试。

顺带一提,#321 那边 MavenTaskStatus 少了 cancelled(这边 MavenTaskState 有),行为对不齐;run.store.ts 里还混进了几处无关的缩进/换行改动。那两条我到 #321 上说。

Comment threadrust/lithe-core/src/execution/configuration.rs Outdated
Comment threadrust/lithe-core/src/execution/configuration.rs
Comment threadrust/lithe-core/src/project/maven.rs Outdated
Comment threadmacos/Sources/LitheExecutionModule/Services/MavenService.swift Outdated
Comment threadrust/lithe-core/src/lsp/interface/engine.rs Outdated
Comment threadshared/contracts/maven-portable-configuration-v1.schema.json
@Mucheen
Mucheenforce-pushed the feat/issue-291-macos-maven branch from 3ae29d7 to f431371CompareAugust 29, 2026 13:46

@1lck1lck left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

重新过了一遍,之前提的 7 条行级问题 + 2 条整体问题全部关掉了,我在本机实跑验证:

  • cargo test:278 passed, 0 failed
  • ./scripts/test-macos.sh691 tests in 79 suites passed —— 上次「0 个用例」的问题解决了,前提条件成立,回归修复是真被验证过的
  • verify-shared-contracts / verify-rust-core-comments / verify-service-boundaries / verify-windows-boundaries:全 PASS

几条修得比我建议的更好:

cwd 没照我给的 != "." 抄,而是加了 configuration_override_has_key 去查 team/local 两层里键是否真的存在。这个判断是对的——我原来的写法会把用户显式写的 cwd: "." 当成默认值吃掉,你这版分得开,而且顺手让 create_user_configuration 不再生成 "cwd": ".",从源头上少了一类歧义。测试也覆盖了 custom-run 保留和默认继承两个方向。

skipTests 用了 Option<bool> 三态而不是 boolSome(false)None 区分开,跑测试的配置能压掉项目级 skipTests=true;还配了 remove_maven_skip_tests_override 和 schema 声明。这块比我说的完整。

-am 变成调用方策略(工具窗口 true / Run false),测试里正反都断言了,包括显式断言 -am 不出现。

fingerprint 现在真的有人读了:recordConfigurationFingerprint 在 run 时比较、refreshConfigurationFingerprint 带 revision 防串,acknowledgeReload 走 baseline。ExecutionModuleTests 里 setSkipTests(true) → reloadRequired、改回去 → 不 required,闭环了。

schema 命名 拆成 portable-configuration 和 launch-context 两份,verify-shared-contracts.sh 里补了逐字段断言($id、字段集、required 集),Maven 不再是「写完没人管」。

摘要漂移platform-contract-v1.json 把两端规范化规则钉住了,macOS 侧抽出 storageIdentity 静态方法给 fixture 消费,lifecycle 九个阶段也一起钉进去 + 一致性测试。这个方案比硬抽一份实现合适。

可以合。剩下两条都是 #321 的活,不拦这个 PR:

  1. platform-contract-v1.json 里 Windows 那条 case 和 lifecyclePhases 目前只有 macOS 侧在消费,Windows 的 maven.rs / maven.types.ts 都在 #321,那边记得把对应的一致性测试补上,不然 fixture 只钉住了一半。
  2. MavenTaskStatuscancelledrun.store.ts 的无关缩进改动,我在 #321 说。

@1lck
1lck merged commit eab95a5 into previewAug 29, 2026
15 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or requestmacossomething related to macos strongly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Mucheen@1lck