From 2ecaefe859744568c04c77cf2f608030f3243741 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Tue, 1 Dec 2026 22:17:51 +0800 Subject: [PATCH] fix(java): normalize Maven system-scope jar paths on Windows (#7248) ${pom.basedir}/src/main/... resolved to a path mixing \\ and / on Windows, so the launch classpath carried it in an odd spelling and the #7226 test failed on the Windows runner. The resolved path is rebuilt from its components. --- crates/ide-build/src/maven.rs | 4 +++- crates/ide-host/src/ops/java.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ide-build/src/maven.rs b/crates/ide-build/src/maven.rs index 5336a7f901..7e16635599 100644 --- a/crates/ide-build/src/maven.rs +++ b/crates/ide-build/src/maven.rs @@ -1555,7 +1555,9 @@ pub fn load_with_linked_jdk( .as_deref() .or_else(|| managed.get(&d.key()).and_then(|m| m.system_path.as_deref()))?; let path = i(path); - (!path.contains("${") && Path::new(&path).is_absolute()).then(|| PathBuf::from(path)) + // Rebuilt from its components: `${pom.basedir}/lib/x.jar` on Windows mixes `\\` and `/`. + (!path.contains("${") && Path::new(&path).is_absolute()) + .then(|| Path::new(&path).components().collect::()) }) .collect(); diff --git a/crates/ide-host/src/ops/java.rs b/crates/ide-host/src/ops/java.rs index fcae67de5d..2a80817890 100644 --- a/crates/ide-host/src/ops/java.rs +++ b/crates/ide-host/src/ops/java.rs @@ -1292,7 +1292,7 @@ mod tests { fn java_server_launch_classpath_includes_local_maven_system_jars() { let tmp = tempfile::tempdir().unwrap(); let root = dunce::canonicalize(tmp.path()).unwrap(); - let jar = root.join("src/main/resources/lib/offline.jar"); + let jar = ["src", "main", "resources", "lib", "offline.jar"].iter().fold(root.clone(), |p, c| p.join(c)); std::fs::create_dir_all(jar.parent().unwrap()).unwrap(); std::fs::write(&jar, "").unwrap(); std::fs::write(