fix(java): preserve mapped toolchain paths and refresh Maven run settings (#1147)

* fix(sdk): keep the drive letter of a Maven home found on a mapped drive

Maven discovery canonicalized mvn on PATH and each Maven home to resolve symlinks (Homebrew's
bin/mvn). On Windows, a home on a mapped network drive or a subst drive then became
\\?\UNC\server\share\… (or another drive), the Maven home setting picked from the list stored
that path, and cmd.exe can't start mvn.cmd from it: every Maven run failed with "The system
cannot find the path specified". Discovery now keeps the path as found when canonicalizing would
change its drive letter.

Refs #822

* fix(sdk): keep the drive letter of a JDK home on a mapped drive

A JDK on a mapped network drive was canonicalized to \\?\UNC\server\share\…
too, so Maven ran with that JAVA_HOME and mvn.cmd failed with "The system
cannot find the path specified" even with a local Maven home. JDK homes
(configured, JAVA_HOME, the java on PATH) now keep their drive letter like
Maven homes do.

* fix(maven): resolve current toolchain settings for each run

* fix(sdk): distinguish mapped roots from external launcher links

* test(run): preserve explicit Maven choices across save and reload

* fix(maven): keep edited nested test launchers when refreshing defaults
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-04 12:35:01 +08:00
1 джерело 0a70b0af01
коміт 60969eccb6
9 files changed
+400 -23

No files matched your search

+18 -4
Переглянути файл
@@ -210,11 +210,25 @@ describe("Maven runs", () => {
});
expect(root.cwd).toBeNull();
expect(root.isTest).toBe(false);
// Settings › Maven options go before the goals.
const configured = { ...core, options: ["-s", "/m2/settings.xml"] };
const configured = {
...core,
command: "//?/UNC/server/share/maven/bin/mvn.cmd",
options: ["-s", "/old/settings.xml", "-Dmaven.repo.local=/old/repository"],
};
const goal = mavenGoalConfig(configured, ["test"], maven, {
offline: false,
skipTests: true,
profiles: {},
});
expect(goal.command).toBe("mvn");
expect(goal.args).toEqual(["test", "-DskipTests"]);
expect(
mavenGoalConfig(configured, ["test"], maven, { offline: false, skipTests: true, profiles: {} }).args,
).toEqual(["-s", "/m2/settings.xml", "test", "-DskipTests"]);
mavenGoalConfig(configured, ["-s", "/own/settings.xml", "test"], maven, {
offline: false,
skipTests: false,
profiles: {},
}).args,
).toEqual(["-s", "/own/settings.xml", "test"]);
});
it("parses typed command lines", () => {
+2 -2
Переглянути файл
@@ -426,12 +426,12 @@ export function mavenGoalConfig(
model: Pick<MavenModel, "profiles">,
options: MavenRunOptions,
): RunConfig {
const args = [...project.options, ...mavenArgs(goals, model, options)];
const args = mavenArgs(goals, model, options);
return {
id: `maven:goal:${project.pom}:${goals.join(" ")}`,
name: mavenConfigName(project, goals),
kind: "maven",
command: project.command,
command: /(?:^|[/\\])mvnw(?:\.cmd|\.bat)?$/i.test(project.command) ? project.command : "mvn",
args,
cwd: project.dir || null,
env: { ...project.env },