We have some projects where we need a sourceCompatibility of 1.8 (because it needs to run on Android), but require the bundle to run on Java 17. Therefore, the Java Build Path in Eclipse should target Java 17, so that the unit tests run with Java 17 and not Java 1.8.
When setting sourceCompatibility = JavaVersion.VERSION_1_8 and omitting targetCompatibility, the build path targets Java 1.8, which is not what we want.
When setting sourceCompatibility = JavaVersion.VERSION_1_8 and targetCompatibility = JavaVersion.VERSION_17, the build path correctly targets Java 17, but the generated Compiler settings are invalid:
Compiler compliance level is set to 1.8
Generated .class files compatibility is set to 17
Source compatibility is set to 1.8
Please note that it is invalid to have a .class files compatibility higher than the compliance level!
What we want is a compiler compliance level of 17, a .class files compatibility of 17 and a source compatibility of 1.8, so the wrong setting is the compiler compliance level.
When trying to enforce this setting in build.gradle with
, the .settings/org.eclipse.jdt.core.prefs file gets correctly generated when running gradlew eclipse, but when importing or synchronizing the project in Eclipse, the .prefs file gets reverted back! Buildship doesn't seem to respect the eclipse.jdt configuration (confirmed by observing that a println there will not be visible when sync'ing the project).
Gradle version: 8.0.2
We have some projects where we need a sourceCompatibility of 1.8 (because it needs to run on Android), but require the bundle to run on Java 17. Therefore, the Java Build Path in Eclipse should target Java 17, so that the unit tests run with Java 17 and not Java 1.8.
sourceCompatibility = JavaVersion.VERSION_1_8
and omittingtargetCompatibility
, the build path targets Java 1.8, which is not what we want.sourceCompatibility = JavaVersion.VERSION_1_8
andtargetCompatibility = JavaVersion.VERSION_17
, the build path correctly targets Java 17, but the generated Compiler settings are invalid:What we want is a compiler compliance level of 17, a .class files compatibility of 17 and a source compatibility of 1.8, so the wrong setting is the compiler compliance level. When trying to enforce this setting in
build.gradle
with, the
.settings/org.eclipse.jdt.core.prefs
file gets correctly generated when runninggradlew eclipse
, but when importing or synchronizing the project in Eclipse, the .prefs file gets reverted back! Buildship doesn't seem to respect the eclipse.jdt configuration (confirmed by observing that aprintln
there will not be visible when sync'ing the project).