diff --git a/crates/ide-sdk/src/apply.rs b/crates/ide-sdk/src/apply.rs index 791c8b4470..30b357aec9 100644 --- a/crates/ide-sdk/src/apply.rs +++ b/crates/ide-sdk/src/apply.rs @@ -2796,6 +2796,16 @@ mod maven_linkage_tests { assert!(nowhere.settings.is_none(), "no usable directory: the import runs without it"); } + #[test] + fn gradle_classpath_script_applies_plugins_to_the_project() { + // Inside the script's closures a bare `apply` is the init script's own: on Gradle 7 the + // Eclipse plugin then fails to start and the whole import fails. + let script = include_str!("gradle-classpath.init.gradle"); + let bare: Vec<&str> = script.lines().filter(|line| line.trim_start().starts_with("apply ")).collect(); + assert!(bare.is_empty(), "{bare:?}"); + assert!(script.contains("project.apply plugin: 'eclipse'")); + } + #[test] fn gradle_import_of_a_gradle_build_runs_on_the_project_jdk_like_the_ides_builds() { let temp = tempfile::tempdir().unwrap(); diff --git a/crates/ide-sdk/src/gradle-classpath.init.gradle b/crates/ide-sdk/src/gradle-classpath.init.gradle index 68c89d4a37..60fc1e5cd7 100644 --- a/crates/ide-sdk/src/gradle-classpath.init.gradle +++ b/crates/ide-sdk/src/gradle-classpath.init.gradle @@ -3,7 +3,9 @@ // compile classpath names, so Java code sees the classes it compiles against. allprojects { plugins.withId('java') { - apply plugin: 'eclipse' + // `project.`: a bare `apply` in this closure is the init script's own (Gradle 7 fails to create the + // plugin then: no IdeArtifactRegistry service). + project.apply plugin: 'eclipse' eclipse.classpath.file.whenMerged { classpath -> def projectOf = { dep -> def path