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
This commit is contained in:
Sam Brannen
2026-10-05 15:56:42 +02:00
parent 328def4b23
commit 46d7ffde9c
2 changed files with 12 additions and 5 deletions
+7 -5
View File
@@ -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 {
+5
View File
@@ -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.