Gradle can download the JDK for you
· #java#gradle#tooling
Gradle 6.8 shipped on 8 January 2021. Reading the release notes, I was surprised to learn that the previous version (6.7) already introduced the ability to automatically install the JDK version your project needs to build.
In build.gradle you declare the JDK version you want:
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
} and at build time Gradle will:
- configure the specified JDK for all
compile,testandjavadoctasks, - detect JDKs installed locally,
- pick a suitable JDK for each task from step 1,
- automatically download any JDK that’s missing in step 3.
Pretty cool, right?
Gradle 6.8 release notes · Toolchain auto-provisioning
Originally posted on my Telegram channel Ламповый ТехДир.