Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/feature-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Local Repository、Offline、Skip Tests,按工作区保存,加到构建、

**依赖的宿主能力**:`settings`(插件设置页和 `reload` 生效方式)、`settingRegions`(设置侧栏搜索关键词定位)、`buildSystems` 的构建选项和可执行文件候选顺序。

**实际值**:模型的 `optionDefaults` 报告 Settings File 和 Local Repository 在不传参数时 Maven 实际使用的值(用户设置文件为 `~/.m2/settings.xml`;本地仓库取本次读取的设置中的 `<localRepository>`,没有时为 `~/.m2/repository`)。宿主(Core `Lithe-core-rust#120`、`#121` 及以后、桌面 [1lck/Lithe-IDEA#2210](https://github.com/1lck/Lithe-IDEA/pull/2210))据此显示 IDEA 式的“覆盖”复选框;旧宿主忽略这两项。2026-11-19 `scripts/test.mjs` 的 `the model reports the settings file and local repository Maven uses` 通过(macOS arm64)。

**最近验证**: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):
Expand Down
33 changes: 31 additions & 2 deletions extension/src/main/java/io/github/litheidea/maven/ModelExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ Map<String, Object> document() {
document.put("tasks", tasks);
document.put("contentRoots", contentRoots);
document.put("optionValues", optionValues);
Map<String, Object> optionDefaults = new LinkedHashMap<>();
if (!defaultProfiles.isEmpty()) {
Map<String, Object> optionDefaults = new LinkedHashMap<>();
optionDefaults.put("profiles", new ArrayList<>(defaultProfiles));
document.put("optionDefaults", optionDefaults);
}
pathDefaults(optionDefaults);
document.put("optionDefaults", optionDefaults);
document.put("optionExcludePrefixes", optionExcludePrefixes);
document.put("optionActiveChoices",
Collections.singletonMap("profiles", new ArrayList<>(activeProfileIds(profiles))));
Expand Down Expand Up @@ -433,6 +434,34 @@ private Settings effectiveSettings(Properties userProperties) {
}
}

/**
* What Maven uses for the Settings File and Local Repository options when
* Lithe passes neither, which Lithe shows greyed until the user checks
* Override, as IntelliJ IDEA's Maven settings do
* ({@code MavenUtil.resolveUserSettingsPath} and
* {@code resolveLocalRepository}): the user settings file is
* {@code ~/.m2/settings.xml}, and the local repository is the one the
* settings this run read name (the user settings file, then the global
* one), else {@code ~/.m2/repository}. The settings read are the
* overridden file when the user set one, so the repository follows it
* as in IDEA. Hosts without this support ignore both entries.
*/
private void pathDefaults(Map<String, Object> optionDefaults) {
File m2 = new File(System.getProperty("user.home"), ".m2");
optionDefaults.put("settingsFile",
Collections.singletonList(new File(m2, "settings.xml").getAbsolutePath()));
String repository = null;
Settings settings = effectiveSettings(cleanUserProperties());
if (settings != null && settings.getLocalRepository() != null
&& !settings.getLocalRepository().trim().isEmpty()) {
repository = new File(settings.getLocalRepository().trim()).getAbsolutePath();
}
if (repository == null) {
repository = new File(m2, "repository").getAbsolutePath();
}
optionDefaults.put("localRepository", Collections.singletonList(repository));
}

private Properties cleanUserProperties() {
Properties cleaned = new Properties();
if (session.getUserProperties() == null) {
Expand Down
25 changes: 20 additions & 5 deletions scripts/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { createReport } from "./report.mjs";
import { BackendClient } from "./compiler/backend-client.mjs";
import { execFileSync } from "node:child_process";
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { homedir, tmpdir } from "node:os";
import { delimiter, join, resolve } from "node:path";

const PACKAGE_DIR = "io.github.lithe-idea.maven-build";
Expand Down Expand Up @@ -241,7 +241,7 @@ async function test(signal) {

await check("profiles become choices of the Profiles option", () => {
assert.deepEqual(model.optionValues.profiles, ["ci", "release"]);
assert.equal(model.optionDefaults, undefined);
assert.equal(model.optionDefaults.profiles, undefined);
assert.deepEqual(model.optionActiveChoices, { profiles: [] });
assert.deepEqual(model.optionExcludePrefixes, { profiles: "-" });
});
Expand Down Expand Up @@ -301,18 +301,18 @@ async function test(signal) {
}
const initial = await readProfileModel("default", "");
assert.deepEqual(initial.optionValues.profiles, ["dev", "prod"]);
assert.deepEqual(initial.optionDefaults, { profiles: ["dev"] });
assert.deepEqual(initial.optionDefaults.profiles, ["dev"]);
assert.deepEqual(initial.optionActiveChoices, { profiles: ["dev"] });
assert.deepEqual(initial.optionExcludePrefixes, { profiles: "-" });
assert.deepEqual(initial.projects.map((project) => project.name), ["profiles-reactor", "dev-module"]);

const switched = await readProfileModel("switched", "-dev,prod");
assert.deepEqual(switched.optionDefaults, { profiles: ["dev"] });
assert.deepEqual(switched.optionDefaults.profiles, ["dev"]);
assert.deepEqual(switched.optionActiveChoices, { profiles: ["prod"] });
assert.deepEqual(switched.projects.map((project) => project.name), ["profiles-reactor", "prod-module"]);

const cleared = await readProfileModel("cleared", "-dev");
assert.deepEqual(cleared.optionDefaults, { profiles: ["dev"] });
assert.deepEqual(cleared.optionDefaults.profiles, ["dev"]);
assert.deepEqual(cleared.optionActiveChoices, { profiles: [] });
assert.deepEqual(cleared.projects.map((project) => project.name), ["profiles-reactor"]);

Expand All @@ -324,6 +324,21 @@ async function test(signal) {
["profiles-reactor", "dev-module", "prod-module"]);
});

await check("the model reports the settings file and local repository Maven uses", async () => {
// Shown greyed until Override, as IDEA's Maven settings: the user settings file is always
// ~/.m2/settings.xml, and the repository is the one the settings read name, else ~/.m2/repository.
const m2 = join(homedir(), ".m2");
const plain = await readProfileModel("paths-default", "");
assert.deepEqual(plain.optionDefaults.settingsFile, [join(m2, "settings.xml")]);
assert.deepEqual(plain.optionDefaults.localRepository, [join(m2, "repository")]);
const repository = join(scratch, "settings-repository");
const settings = join(scratch, "paths-settings.xml");
writeFileSync(settings, `<settings><localRepository>${repository}</localRepository></settings>`);
const named = await readProfileModel("paths-settings", "", settings);
assert.deepEqual(named.optionDefaults.settingsFile, [join(m2, "settings.xml")]);
assert.deepEqual(named.optionDefaults.localRepository, [repository]);
});

await check("packaging activation is reflected in baseline defaults and can be disabled", async () => {
const pom = join(profileRoot, "pom.xml");
const original = readFileSync(pom, "utf8");
Expand Down
Loading