fix(java): apply the Eclipse plugin to the project in the Gradle classpath init script (#5677)

Inside the Gradle classpath init script's closures a bare `apply plugin: 'eclipse'` resolves to the init script's own apply. On Gradle 7 the Eclipse plugin then can't get its project services (no IdeArtifactRegistry), applying java fails, and jdtls's Gradle import fails for every Gradle 7 project, leaving all Java files red. The script now calls project.apply; a test keeps bare apply calls out of it.

Fixes #5669
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-25 04:37:46 +08:00
1 джерело 7532ff30fd
коміт af3e174702
2 files changed
+13 -1

No files matched your search

+10
Переглянути файл
@@ -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();
+3 -1
Переглянути файл
@@ -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