Skip to content

Commit

Permalink
Adopt Gradle Toolchain for the JDK (#2343)
Browse files Browse the repository at this point in the history
Adopting the Gradle Toolchain for the JDK will make the build _safer_ in machines that have multiple JDKs
installed and that by mistake can build the project using a JDK higher than the intended.

As defined in [Gradle's docs](https://docs.gradle.org/current/userguide/toolchains.html), the toolchains will give us...

> Executing the build (e.g. using gradle check) will now handle several things for you and others running your build
> Setup all compile, test and javadoc tasks to use the defined toolchain which may be different than the one Gradle itself uses
> Gradle detects locally installed JVMs
> Gradle chooses a JRE/JDK matching the requirements of the build (in this case a JVM supporting Java 8)
> If no matching JVM is found, it will automatically download a matching JDK from AdoptOpenJDK
  • Loading branch information
berngp authored and violetagg committed Jul 4, 2022
1 parent 2284bb2 commit 6ec064f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions build.gradle
Expand Up @@ -175,8 +175,12 @@ subprojects {
apply from: "${rootDir}/gradle/javadoc.gradle"
apply from: "${rootDir}/gradle/errorprone.gradle"

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

jacoco {
toolVersion = '0.8.7'
Expand Down Expand Up @@ -213,16 +217,6 @@ subprojects {
"-Xlint:rawtypes"
]

compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

if (JavaVersion.current().isJava8Compatible()) {
compileTestJava.options.compilerArgs += "-parameters"
tasks.withType(Javadoc) {
Expand Down

0 comments on commit 6ec064f

Please sign in to comment.