Require JDK 11 or 17 for building project
While we intend to continue supporting JDK 8 compatibility at runtime, we have a build matrix that will continue to get more complicated as more LTS Java releases become available. We recently ran into #3136 where a sample needs JDK 11+ with the latest dependencies. Released artifacts are built with the latest available JDK, but we also have builds for each LTS to ensure the project can be built with older versions. This is a convenience to contributors, but it is becoming more reasonable to require a contributor to have a recent version of the JDK configured for building the project. Using the compiler -release flag, we will ensure API compatibility with JDK 8 while building with newer JDKs.
When we drop JDK 8 or 8/11 builds, we might still want to run tests on those JVMs.
When we drop JDK 8 or 8/11 builds, we might still want to run tests on those JVMs.
In order to do that, we will need a build image that has multiple Java versions, which comes with its own complexity. We would probably need to maintain our own custom build image, unless someone is aware of an alternative that doesn't require us to maintain our own.
We could use the Gradle's toolchain option - I wonder if that can be parameterized. Then we could run it with different parameters like 8, 11, 17 etc. (pseudocode below)
jdkVersion = project.getProperty("jdkVersion") ?: 11
java {
toolchain {
languageVersion = JavaLanguageVersion.of(jdkVersion)
}
}
tasks.withType(JavaCompile) {
options.release.set(jdkVersion)
}