-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Gradle Toolchains for JVM projects to test on unsupported JDK versions #25787
Comments
Depends on #25918. |
Beginning with Gradle 6.8, it will also be possible to track the vendor and implementation of the JVM for caching purposes. See gradle/gradle#9102 (comment) for details. |
Here's a proposal for introducing Gradle Toolchains in our build. This changes two things:
Gradle JVM ToolchainThis proposal is configuring Java, Kotlin and Groovy compilation with the following behavior:
You can use that locally. If Gradle detects the required JDKs it will use them, otherwise Gradle will download the AdoptOpenJDK one automcatically. You can check which JDKs are detected on your host with $ ./gradlew -q javaToolchains This is rather flexible and allows to:
Concourse buildThe Concourse build now produces a single CI docker image for the entire pipeline; this image contains all the JDKs we need so far: JDK8, JDK11, JDK15. It is easy to add/remove JDKs from our setup. All JDKs locations are configured as environment variables, which makes them available to Gradle. The pipeline now has:
We can of course discuss options here. Let me know what you think! |
This commit fixes various issues with the configuration of the Gradle Java toolchain in the build. First, the configuration of build properties is fixed in the CI pipeline because it wasn't properly checked. The JMH plugin is also upgraded and we now configure its toolchain support. This commit also rewrites the XJC tasks in the spring-oxm module, leveraging a Gradle plugin that creates actual compile tasks we can configure. See gh-25787
Commit 3eec27a introduced a custom resource filter for projects imported into Eclipse IDE. However, commit 85eb589 introduced generated source files within the Gradle 'build' folder, and the filter prevents Eclipse from seeing the generated sources, resulting in build errors within the spring-oxm project in Eclipse. This commit therefore effectively reverts 3eec27a by removing the resource filter. See gh-25787
Prior to this commit, the task parameters for the CI project checks were overridden by a task anchor. This commit splits the anchor declaration and ensures that the `TEST_TOOLCHAIN` setting is set for the JDK variant builds. See gh-25787
Prior to this commit, we registered custom values in the build scan for the main and test toolchains based on input values provided via the mainToolchain and testToolchain project properties. Beginning with this commit, the custom values we register are based on the available metadata for the resolved JDK/JVM for each toolchain. For example, instead of registering the following custom value... Test toolchain : JDK11 ... we now register the following which includes the vendor, version, and installation path of the JDK/JVM. Test toolchain : AdoptOpenJDK 11 (/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home) Once Gradle's JavaInstallationMetadata includes the exact version, we will likely use that instead of the installation path. See gh-25787
Prior to this commit, the Spring Framework build would rely on setting a custom Java HOME for building all sources and tests with that JDK. This approach is not flexible enough, since we would be testing the source compatibility against a recent JDK, but not a common case experienced by the community: compiling and running application code with a recent JDK and the official, JDK8-based Framework artifacts. This method is also limiting our choice of JDKs to the ones currently supported by Gradle itself. This commit introduces the support of Gradle JVM Toolchains in the Spring Framework build. We can now select a specific JDK for compiling the main SourceSets (Java, Groovy and Kotlin) and another one for compiling and running the test SourceSets: `./gradlew check -PmainToolChain=8 -PtestToolchain=15` Gradle will automatically find the JDKs present on the host or download one automcatically. You can find out about the ones installed on your host using: `./gradlew -q javaToolchains` Finally, this commit also refactors the CI infrastructure to: * only have a single CI image (with all the supported JDKs) * use this new feature to compile with JDK8 but test it against JDK11 and JDK15. Closes spring-projectsgh-25787
This commit fixes various issues with the configuration of the Gradle Java toolchain in the build. First, the configuration of build properties is fixed in the CI pipeline because it wasn't properly checked. The JMH plugin is also upgraded and we now configure its toolchain support. This commit also rewrites the XJC tasks in the spring-oxm module, leveraging a Gradle plugin that creates actual compile tasks we can configure. See spring-projectsgh-25787
Commit 3eec27a introduced a custom resource filter for projects imported into Eclipse IDE. However, commit 85eb589 introduced generated source files within the Gradle 'build' folder, and the filter prevents Eclipse from seeing the generated sources, resulting in build errors within the spring-oxm project in Eclipse. This commit therefore effectively reverts 3eec27a by removing the resource filter. See spring-projectsgh-25787
Prior to this commit, the task parameters for the CI project checks were overridden by a task anchor. This commit splits the anchor declaration and ensures that the `TEST_TOOLCHAIN` setting is set for the JDK variant builds. See spring-projectsgh-25787
Prior to this commit, we registered custom values in the build scan for the main and test toolchains based on input values provided via the mainToolchain and testToolchain project properties. Beginning with this commit, the custom values we register are based on the available metadata for the resolved JDK/JVM for each toolchain. For example, instead of registering the following custom value... Test toolchain : JDK11 ... we now register the following which includes the vendor, version, and installation path of the JDK/JVM. Test toolchain : AdoptOpenJDK 11 (/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home) Once Gradle's JavaInstallationMetadata includes the exact version, we will likely use that instead of the installation path. See spring-projectsgh-25787
Gradle 6.7 will introduce built-in support for Toolchains for JVM projects.
Once we upgrade to Gradle 6.7, we will should hopefully be able to replace the functionality in
custom-java-home.gradle
with the new built-in support.Note from the Gradle team:
The text was updated successfully, but these errors were encountered: