From 2389c0e07ea61a9d028d39b4b11fcd9430dc299a Mon Sep 17 00:00:00 2001 From: "arookieofc-ai[bot]" <2128194521hzz@gmail.com> Date: Sat, 5 Dec 2026 09:11:21 +0800 Subject: [PATCH] fix(java): wait out multi-module Maven imports (#8008) Part of #772. Co-authored-by: arookieofc Co-authored-by: hpz --- crates/ide-lsp/src/jdtls.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/ide-lsp/src/jdtls.rs b/crates/ide-lsp/src/jdtls.rs index fbd3228d77..94b0d5eb09 100644 --- a/crates/ide-lsp/src/jdtls.rs +++ b/crates/ide-lsp/src/jdtls.rs @@ -43,8 +43,10 @@ const READY_TIMEOUT: Duration = Duration::from_secs(240); /// an editor request; the user can always cancel the launch waiting on it. const BUILD_TIMEOUT: Duration = Duration::from_secs(20 * 60); const COMMAND_TIMEOUT: Duration = Duration::from_secs(120); -/// How long to retry while the project is still being imported. -const IMPORT_WAIT: Duration = Duration::from_secs(90); +/// How long to retry while the project is still being imported. The first import of a large +/// multi-module Maven project takes minutes, and m2e only registers the aggregator project at +/// the very end, so this must cover it rather than a few seconds. +const IMPORT_WAIT: Duration = Duration::from_secs(240); /// Compile errors listed with a launch; the rest are only counted. const MAX_LAUNCH_ERRORS: usize = 10; /// Build markers can be published just after `java/buildWorkspace` answers. @@ -575,6 +577,9 @@ fn not_imported(e: &IdeError) -> bool { || m.contains("not a java project") || m.contains("no project") || m.contains("cannot find") + // `java.project.getClasspaths` fails this way while m2e is still importing: the temporary + // launch configuration names a Maven project the Eclipse workspace has not registered yet. + || m.contains("references non-existing project") } const BUILD_FILES: [&str; 5] = @@ -2013,6 +2018,9 @@ mod tests { fn error_classification() { let e = IdeError::invalid("Given URI does not belong to any Java project."); assert!(not_imported(&e)); + assert!(not_imported(&IdeError::invalid( + "Launch configuration 1793342372874 references non-existing project knowledge." + ))); assert!(missing_bundle(&IdeError::invalid("No delegateCommandHandler for vscode.java.startDebugSession"))); assert!(!missing_bundle(&e)); }