From 46d7ffde9cc971fe086ad19d2af8fc5f95c12ecd Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Mon, 5 Oct 2026 15:56:42 +0200 Subject: [PATCH] Exclude multi-release outputs from Eclipse classpath Although the multi-release source sets in spring-core were already excluded from the Eclipse classpath, their Gradle output directories (such as build/classes/java/java21) were still added as libraries once they existed, resulting in duplicate types on the classpath. This commit removes those entries as well, generalizes the exclusion to any Java release version, revises the outdated comment in ide.gradle, and documents the limitation in the Eclipse import instructions. See gh-37397 --- gradle/ide.gradle | 12 +++++++----- import-into-eclipse.md | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gradle/ide.gradle b/gradle/ide.gradle index a6d561e76b3..c39673c3a84 100644 --- a/gradle/ide.gradle +++ b/gradle/ide.gradle @@ -68,14 +68,16 @@ eclipse.classpath.file.whenMerged { } } -// Remove Java 21 classpath entries, since we currently use Java 17 -// within Eclipse. Consequently, Java 21 features managed via the -// me.champeau.mrjar plugin cannot be built or tested within Eclipse. +// Remove classpath entries for multi-release source sets (such as "src/main/java21") +// and their Gradle output (such as "build/classes/java/java21"), since an Eclipse +// project supports only a single Java compliance level. Consequently, features +// managed via the multiReleaseJar plugin cannot be built or tested within Eclipse. eclipse.classpath.file.whenMerged { classpath -> - classpath.entries.removeAll { it.path =~ /src\/(main|test)\/java(21|24)/ } + classpath.entries.removeAll { it.path =~ /src\/(main|test)\/java\d+/ } + classpath.entries.removeAll { it.path =~ /build\/classes\/[^\/]+\/java\d+(Test)?$/ } } -// Remove classpath entries for non-existent libraries added by the me.champeau.mrjar +// Remove classpath entries for non-existent libraries added by the multiReleaseJar // plugin, such as "spring-core/build/classes/kotlin/java21". eclipse.classpath.file.whenMerged { entries.findAll { it instanceof Library && !file(it.path).exists() }.each { diff --git a/import-into-eclipse.md b/import-into-eclipse.md index 65f6bf7351f..b486406c945 100644 --- a/import-into-eclipse.md +++ b/import-into-eclipse.md @@ -53,6 +53,11 @@ within your locally cloned `spring-framework` working directory._ compile `spring-core` and generate JAXB types for `spring-oxm`. 1. `spring-aspects` does not compile due to references to aspect types unknown to Eclipse. - If you installed _AJDT_ into Eclipse it should work. +1. The Java 21 and Java 24 multi-release sources in `spring-core` (`src/main/java21`, + `src/main/java24`, and `src/test/java21`) are not configured as source folders in + Eclipse, since an Eclipse project supports only a single Java compliance level. + - Use `./gradlew :spring-core:java21Test` or `./gradlew :spring-core:java24Test` to + build and test those sources from the command line. 1. While JUnit tests pass from the command line with Gradle, some may fail when run from the IDE. - Resolving this is a work in progress.