From 17d759800888fa3b276eeaa41b36e093f87d344f Mon Sep 17 00:00:00 2001 From: lick <2188718831@qq.com> Date: Wed, 18 Nov 2026 22:01:31 -0800 Subject: [PATCH] =?UTF-8?q?feat(maven):=20=E5=A3=B0=E6=98=8E=20Maven=20?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E9=85=8D=E7=BD=AE=E7=B1=BB=E5=9E=8B=E3=80=81?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=89=8D=E4=BB=BB=E5=8A=A1=E4=B8=8E=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=90=9C=E7=B4=A2=E5=85=B3=E9=94=AE=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/feature-matrix.md | 31 ++++- .../l10n/zh-Hans.json | 75 +++++++++++ io.github.lithe-idea.maven-build/plugin.json | 117 +++++++++++++++++- scripts/test.mjs | 31 +++++ 4 files changed, 247 insertions(+), 7 deletions(-) diff --git a/docs/feature-matrix.md b/docs/feature-matrix.md index 286f52d..fe53589 100644 --- a/docs/feature-matrix.md +++ b/docs/feature-matrix.md @@ -26,14 +26,15 @@ CI 在 Windows x64 上用 `mvn.cmd` 运行声明的模型、依赖和测试命 | --- | --- | --- | --- | --- | | `java-maven-project` | 识别 Maven 项目:构建根、模块树、内容根和任务 | implemented / pending | implemented / pending | 2026-11-14 宿主端到端测试通过(macOS) | | `java-maven-profiles-dependencies` | Profiles 构建选项与依赖树 | implemented / pending | implemented / pending | 2026-11-14 依赖树由宿主端到端测试覆盖(macOS) | -| `java-maven-project-settings` | Maven 调用设置:Maven 程序和工作区构建选项 | partial / pending | partial / pending | 2026-11-14 Maven executable 由宿主端到端测试覆盖(macOS) | +| `java-maven-project-settings` | Maven 调用设置:Maven 程序、工作区构建选项、`settingRegions` 搜索关键词与中文翻译 | partial / pending | partial / pending | 2026-11-18 `settingRegions`(`build`、`compiler`)、`settings.mavenExecutable`、`sections.Maven` 通过 Core `9dea6aa` 校验与 `scripts/test.mjs`;2026-11-14 Maven executable 由宿主端到端测试覆盖(macOS) | | `java-maven-settings-reach-jdt` | Maven 构建选项作用于 Java 语言服务 | missing / not-applicable | missing / not-applicable | — | | `java-maven-toolbar-tooltips` | 构建窗口里的 Maven 图标、工具栏开关和提示 | implemented / pending | implemented / pending | 没有自动化覆盖 | | `maven-user-settings-editing` | 编辑用户级 `~/.m2/settings.xml` 的本地仓库 | missing / not-applicable | missing / not-applicable | — | | `maven-project-generators` | 新建项目:Maven 和 Maven Archetype | implemented / pending | implemented / pending | 2026-11-14 宿主端到端测试通过(macOS) | | `maven-run-applications` | 运行配置:Spring Boot 服务和 Java 应用的运行与调试 | implemented / pending | implemented / pending | 2026-11-17 宿主端到端测试(运行与断点调试)和 `scripts/test.mjs` 通过(macOS);`scripts/test.mjs` 在 Windows CI 通过 | +| `maven-task-run-configurations` | 声明式 Maven 任务型运行配置(`Maven`)与启动前任务(`Run Maven Goal` / `运行 Maven 目标`),含中英文翻译 | implemented / pending | implemented / pending | 2026-11-18 通过 Core `9dea6aa`(`runConfig.configurationTypes` / `runConfig.editorForm`)、`scripts/test.mjs` 及宿主 Viva 无头渲染预览(macOS) | -前六条从主仓库迁移;`maven-project-generators` 是本仓库新增,用来记录随测试一起迁来的新建项目测试;`maven-run-applications` 随运行配置一起新增([1lck/Lithe-IDEA#2074](https://github.com/1lck/Lithe-IDEA/issues/2074))。 +前六条从主仓库迁移;`maven-project-generators` 是本仓库新增,用来记录随测试一起迁来的新建项目测试;`maven-run-applications` 随运行配置一起新增([1lck/Lithe-IDEA#2074](https://github.com/1lck/Lithe-IDEA/issues/2074));`maven-task-run-configurations` 记录按新版插件 UI 契约新增的声明式 Maven 任务运行配置与启动前任务。 ## java-maven-project @@ -94,12 +95,12 @@ Local Repository、Offline、Skip Tests,按工作区保存,加到构建、 | macOS | partial | pending | 构建选项按工作区保存,不能给单个子项目设置不同的 JDK 或选项 | | Windows | partial | pending | 同 macOS;Windows 上按 `mvnw.cmd`、`MAVEN_HOME\bin\mvn.cmd`、`PATH` 上的 `mvn`(`mvn.cmd`)的顺序查找 Maven | -**证据**:`plugin.json` 的 `settings`(`mavenExecutable`)、`buildSystems[0].invocation` 和 `buildSystems[0].options`; +**证据**:`plugin.json` 的 `settings`(`mavenExecutable`)、`settingRegions`(`build`、`compiler`)、`buildSystems[0].invocation` 和 `buildSystems[0].options`,`l10n/zh-Hans.json`(`settings.mavenExecutable`、`sections.Maven`、`settingRegions.build`、`settingRegions.compiler`),以及 `scripts/test.mjs`; 宿主端到端测试设置 Maven executable 后检查模型重新读取和 `compile` 都运行了设置的 `mvn`。 -**依赖的宿主能力**:`settings`(插件设置页和 `reload` 生效方式)、`buildSystems` 的构建选项和可执行文件候选顺序。 +**依赖的宿主能力**:`settings`(插件设置页和 `reload` 生效方式)、`settingRegions`(设置侧栏搜索关键词定位)、`buildSystems` 的构建选项和可执行文件候选顺序。 -**最近验证**:2026-11-14,macOS arm64,插件 0.0.1 发布包,宿主 `059d878d4`,`node scripts/e2e-host.mjs`:`TestOfficialMavenPluginBuildsAReactor` 设置 Maven executable 为一个包装脚本后,确认模型重新读取和 `compile` 都运行了它。六个构建选项、按工作区保存和 `mvnw` / `MAVEN_HOME` 的候选顺序没有自动化覆盖。 +**最近验证**:2026-11-18,`plugin.json` 与 `l10n/zh-Hans.json` 经 Core `9dea6aa6eaaf830c3568b647aa7daae5018b9727` schema 与 `plugins.settings.catalog` / `plugins.declarative.settingsState` 校验,`scripts/test.mjs` 断言全部通过,并在宿主 Viva 无头设置窗口验证中文分组名与关键词检索。2026-11-14,macOS arm64,插件 0.0.1 发布包,宿主 `059d878d4`,`node scripts/e2e-host.mjs`:`TestOfficialMavenPluginBuildsAReactor` 设置 Maven executable 为一个包装脚本后,确认模型重新读取和 `compile` 都运行了它。六个构建选项、按工作区保存和 `mvnw` / `MAVEN_HOME` 的候选顺序没有自动化覆盖。 **验证方法**(macOS): @@ -238,3 +239,23 @@ Spring Boot 运行声明了按配置类型连接的调试:宿主带调试端 4. 同时安装 Java Support,在 Spring Boot 应用里设断点后点调试:断点命中,继续后请求完成,停止后服务结束。 5. 制造编译错误后运行,看到“Maven 编译失败”的提示,没有启动残缺的应用。 6. 整个过程中插件安装目录不被写入。 + +## maven-task-run-configurations + +**能力**:声明式 Maven 任务型运行配置类型 `Maven`(`buildSystems[0].runConfigurationTypes`,`execution: "task"`),提供 `Command line` / `命令行`(`goals`)、`Profiles`(`profiles`)、`Skip tests` / `跳过测试`(`skipTests`,`-DskipTests`)、`Work offline` / `离线工作`(`offline`,`-o`)四个表单字段;同时声明启动前任务 `Run Maven Goal` / `运行 Maven 目标`(`beforeLaunchTasks` 中的 `goal`,可添加到任意运行配置的 Before Launch 列表,在工作目录执行指定的 Maven 目标或阶段)。 + +| 平台 | 实现 | 验证 | 说明 | +| --- | --- | --- | --- | +| macOS | implemented | pending | 纯声明式清单与翻译,需宿主声明 `runConfigurationTypes: 0` 与 `beforeLaunchTasks: 0` | +| Windows | implemented | pending | 与 macOS 使用同一份跨平台声明和翻译,待 Windows 实机验收 | + +**证据**:`io.github.lithe-idea.maven-build/plugin.json`(`requires.runConfigurationTypes`、`requires.beforeLaunchTasks`、`buildSystems[0].runConfigurationTypes`、`buildSystems[0].beforeLaunchTasks`)、`io.github.lithe-idea.maven-build/l10n/zh-Hans.json`(`runConfigurationTypes.maven.maven`、`beforeLaunchTasks.maven.goal`)、`scripts/test.mjs`。 + +**依赖的宿主能力**:`runConfigurationTypes: 0`、`beforeLaunchTasks: 0`。 + +**最近验证**:2026-11-18,macOS arm64:通过 Core `9dea6aa6eaaf830c3568b647aa7daae5018b9727` JSON Schema 校验以及 `runConfig.configurationTypes` / `runConfig.editorForm` 语义校验(`applied: "l10n/zh-Hans.json"`、`rejected: []`);`node scripts/test.mjs` 通过清单与中文翻译结构断言;宿主 Viva 无头运行配置编辑窗口与 Before Launch 弹窗渲染通过。真实点击运行配置执行 Maven 任务的端到端宿主 UI 交互仍待手工验收。 + +**验证方法**(macOS): + +1. 在运行配置编辑器中新建 `Maven` 配置,分别测试输入 `goals`、`profiles`、`skipTests`、`offline` 并保存与运行,确认拼接的 `mvn` 参数准确无误。 +2. 在其他运行配置(如 Spring Boot)的“启动前(Before Launch)”列表添加“运行 Maven 目标”,确认启动主进程前先执行指定 Maven 目标且中文标题与说明显示完整。 diff --git a/io.github.lithe-idea.maven-build/l10n/zh-Hans.json b/io.github.lithe-idea.maven-build/l10n/zh-Hans.json index b3530d6..9bef1d6 100644 --- a/io.github.lithe-idea.maven-build/l10n/zh-Hans.json +++ b/io.github.lithe-idea.maven-build/l10n/zh-Hans.json @@ -1,4 +1,15 @@ { + "$schema": "https://raw.githubusercontent.com/Lithe-IDEA/Lithe-core-rust/main/shared/plugins/contract/v1/plugin-l10n.schema.json", + "settings": { + "mavenExecutable": { + "title": "Maven 程序", + "description": "要运行的 mvn 程序。留空时依次使用项目的 Maven Wrapper(mvnw)、MAVEN_HOME 和 PATH 中的 mvn;填写后总是使用指定路径,即使项目带有 Wrapper。", + "placeholder": "自动:mvnw、MAVEN_HOME、PATH" + } + }, + "sections": { + "Maven": "Maven" + }, "settingActions": { "compiler": { "title": "使用项目工具读取编译设置", @@ -8,5 +19,69 @@ "title": "读取本地 JAR 依赖", "description": "读取项目实际引用的 JAR;保存时更新页面列出的原生配置文件。读取可能执行项目代码并下载依赖。" } + }, + "settingRegions": { + "build": { + "keywords": [ + "Maven 程序", + "构建选项", + "本地仓库", + "配置文件", + "依赖", + "包装器" + ] + }, + "compiler": { + "keywords": [ + "Maven 编译器", + "编译插件", + "源代码版本", + "目标版本", + "编码" + ] + } + }, + "runConfigurationTypes": { + "maven": { + "maven": { + "displayName": "Maven", + "description": "用 mvn 运行 Maven 目标、生命周期阶段和选项。", + "fields": { + "goals": { + "title": "命令行", + "description": "要运行的 Maven 目标、阶段和选项,例如 clean package 或 test -Dtest=MyTest。", + "placeholder": "clean package" + }, + "profiles": { + "title": "Profiles", + "description": "逗号分隔的 Maven Profile 列表;以 ! 或 - 开头表示取消激活,作为 -P 传入。", + "placeholder": "dev, -integration" + }, + "skipTests": { + "title": "跳过测试", + "description": "传入 -DskipTests,编译测试源码但不运行测试。" + }, + "offline": { + "title": "离线工作", + "description": "传入 -o,只从本地仓库解析依赖。" + } + } + } + } + }, + "beforeLaunchTasks": { + "maven": { + "goal": { + "displayName": "运行 Maven 目标", + "description": "启动前在运行配置的工作目录里运行 Maven 目标或阶段,例如 compile 或 test-compile。", + "fields": { + "goals": { + "title": "命令行", + "description": "启动前要运行的 Maven 目标、阶段和选项,例如 compile 或 package -DskipTests。", + "placeholder": "compile" + } + } + } + } } } diff --git a/io.github.lithe-idea.maven-build/plugin.json b/io.github.lithe-idea.maven-build/plugin.json index 42ff76b..b7ca6c7 100644 --- a/io.github.lithe-idea.maven-build/plugin.json +++ b/io.github.lithe-idea.maven-build/plugin.json @@ -4,7 +4,7 @@ "displayName": "Maven", "version": "1.0.1", "pluginAPIVersion": 0, - "requires": {"buildSystems": 0, "buildProviders": 1, "projectGenerators": 0, "settings": 0, "backend": 0, "sourceSettings": 0}, + "requires": {"buildSystems": 0, "buildProviders": 1, "projectGenerators": 0, "runConfigurationTypes": 0, "beforeLaunchTasks": 0, "settings": 0, "backend": 0, "sourceSettings": 0}, "vendor": {"id": "io.github.lithe-idea", "displayName": "Lithe Community", "signatureRequirement": "none"}, "permissions": ["process.build", "project.generate", "backend.launch", "languageServer.launch", "workspace.metadata"], "activationEvents": ["onBuildSystem:maven"], @@ -329,6 +329,85 @@ "executesProjectCode": true, "mayUseNetwork": true }, + "runConfigurationTypes": [ + { + "id": "maven", + "displayName": "Maven", + "description": "Runs Maven goals, lifecycle phases and options with mvn.", + "icon": { + "path": "icons/maven.svg" + }, + "execution": "task", + "fields": [ + { + "id": "goals", + "title": "Command line", + "description": "Maven goals, phases and options to run, such as clean package or test -Dtest=MyTest.", + "kind": "arguments", + "placeholder": "clean package", + "required": true + }, + { + "id": "profiles", + "title": "Profiles", + "description": "Comma-separated Maven profiles to activate, or prefix with ! or - to deactivate, passed as -P.", + "kind": "text", + "placeholder": "dev, -integration", + "arguments": [ + "-P", + "${value}" + ] + }, + { + "id": "skipTests", + "title": "Skip tests", + "description": "Pass -DskipTests so test sources are compiled without running the tests.", + "kind": "checkbox", + "arguments": [ + "-DskipTests" + ] + }, + { + "id": "offline", + "title": "Work offline", + "description": "Pass -o so Maven resolves dependencies only from the local repository.", + "kind": "checkbox", + "arguments": [ + "-o" + ] + } + ], + "arguments": [ + "${field:goals}", + "${field:profiles}", + "${field:skipTests}", + "${field:offline}" + ] + } + ], + "beforeLaunchTasks": [ + { + "id": "goal", + "displayName": "Run Maven Goal", + "description": "Runs Maven goals or phases, such as compile or test-compile, in the configuration's working directory before launch.", + "icon": { + "path": "icons/maven.svg" + }, + "fields": [ + { + "id": "goals", + "title": "Command line", + "description": "Maven goals, phases and options to run before launch, such as compile or package -DskipTests.", + "kind": "arguments", + "placeholder": "compile", + "required": true + } + ], + "arguments": [ + "${field:goals}" + ] + } + ], "run": [ {"id": "spring-boot", "source": "provider", "fromTargets": {"tags": ["spring-boot"]}, "execution": "service", "debug": {"configurationType": "java"}}, {"id": "application", "source": "provider", "fromTargets": {"tags": ["java-application"]}, "execution": "application"}, @@ -543,5 +622,39 @@ ], "requiresTools": ["java"], "backend": {"launch": {"kind": "runtime", "tool": "java", "minimumVersion": "8", "entry": "lib/lithe-maven-settings.jar", "runtimeArguments": ["-Xms16m", "-Xmx96m"]}}, - "settingActions": [{"id": "compiler", "title": "Read compiler settings", "description": "Read actual project settings using the project tool. This can execute project code and download dependencies. Save writes the displayed native configuration files.", "function": "compiler.settings", "sourceEditor": {"editFunction": "compiler.prepareSettings", "buildSystemID": "maven"}, "page": {"compilerID": "maven"}}, {"id": "libraries", "title": "Read local JAR dependencies", "description": "Read actual project settings using the project tool. This can execute project code and download dependencies. Save writes the displayed native configuration files.", "function": "libraries.settings", "sourceEditor": {"editFunction": "compiler.prepareSettings", "buildSystemID": "maven"}, "page": {"buildSystemID": "maven"}}] + "settingActions": [{"id": "compiler", "title": "Read compiler settings", "description": "Read actual project settings using the project tool. This can execute project code and download dependencies. Save writes the displayed native configuration files.", "function": "compiler.settings", "sourceEditor": {"editFunction": "compiler.prepareSettings", "buildSystemID": "maven"}, "page": {"compilerID": "maven"}}, {"id": "libraries", "title": "Read local JAR dependencies", "description": "Read actual project settings using the project tool. This can execute project code and download dependencies. Save writes the displayed native configuration files.", "function": "libraries.settings", "sourceEditor": {"editFunction": "compiler.prepareSettings", "buildSystemID": "maven"}, "page": {"buildSystemID": "maven"}}], + "settingRegions": [ + { + "id": "build", + "page": { + "buildSystemID": "maven" + }, + "keywords": [ + "mvn", + "mvnw", + "Maven Wrapper", + "MAVEN_HOME", + "pom.xml", + "settings.xml", + "localRepository", + ".m2", + "profiles", + "dependencies" + ] + }, + { + "id": "compiler", + "page": { + "compilerID": "maven" + }, + "keywords": [ + "maven-compiler-plugin", + "javac", + "release", + "source", + "target", + "encoding" + ] + } + ] } diff --git a/scripts/test.mjs b/scripts/test.mjs index a8be347..5f43ae0 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -443,6 +443,37 @@ async function test(signal) { cwd: root, stdio: ["ignore", "ignore", "inherit"], timeoutMs, signal, }); }); + + await check("the manifest declares Maven task run configurations, before-launch tasks and setting regions", () => { + assert.equal(manifest.requires?.runConfigurationTypes, 0); + assert.equal(manifest.requires?.beforeLaunchTasks, 0); + + const mavenConfig = (buildSystem.runConfigurationTypes ?? []).find((item) => item.id === "maven"); + assert.ok(mavenConfig, "maven runConfigurationType must exist"); + assert.equal(mavenConfig.execution, "task"); + assert.deepEqual( + mavenConfig.fields.map((field) => field.id), + ["goals", "profiles", "skipTests", "offline"], + ); + + const goalTask = (buildSystem.beforeLaunchTasks ?? []).find((item) => item.id === "goal"); + assert.ok(goalTask, "goal beforeLaunchTask must exist"); + assert.deepEqual(goalTask.fields.map((field) => field.id), ["goals"]); + + const regions = Object.fromEntries((manifest.settingRegions ?? []).map((region) => [region.id, region])); + assert.equal(regions.build?.page?.buildSystemID, "maven"); + assert.ok(Array.isArray(regions.build?.keywords) && regions.build.keywords.length > 0); + assert.equal(regions.compiler?.page?.compilerID, "maven"); + assert.ok(Array.isArray(regions.compiler?.keywords) && regions.compiler.keywords.length > 0); + + const zh = JSON.parse(readFileSync(join(pluginDir, "l10n", "zh-Hans.json"), "utf8")); + assert.ok(zh.settings?.mavenExecutable?.title, "zh-Hans settings.mavenExecutable"); + assert.ok(zh.sections?.Maven, "zh-Hans sections.Maven"); + assert.ok(Array.isArray(zh.settingRegions?.build?.keywords) && zh.settingRegions.build.keywords.length > 0); + assert.ok(Array.isArray(zh.settingRegions?.compiler?.keywords) && zh.settingRegions.compiler.keywords.length > 0); + assert.ok(zh.runConfigurationTypes?.maven?.maven?.displayName, "zh-Hans runConfigurationTypes.maven.maven"); + assert.ok(zh.beforeLaunchTasks?.maven?.goal?.displayName, "zh-Hans beforeLaunchTasks.maven.goal"); + }); } catch (error) { failed = true; report.failure("integration lane failed", error);