eclipse-buildship / buildship

The Eclipse Plug-ins for Gradle project.
535 stars 171 forks source link

Wrong settings when sourceCompatibility != targetCompatibility #1231

Open andilem opened 1 year ago

andilem commented 1 year ago

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.

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

eclipse.jdt.file.withProperties {
    it.put('org.eclipse.jdt.core.compiler.compliance', targetCompatibility.majorVersion)
}

, 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).