diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36cd46fb..f1e14f6d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' + # The target JDK is used to build, the latest one to run Gradle itself java-version: | ${{ matrix.java-version }} 21 diff --git a/build.gradle b/build.gradle index 6b1b7334..47acedda 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ plugins { var javaToolchain = System.getenv('JAVA_TOOLCHAIN') java { + // If running from CI, the tool chain will be present if (javaToolchain != null) { toolchain { languageVersion = JavaLanguageVersion.of(javaToolchain) @@ -16,15 +17,19 @@ java { } } +println(javaToolchain) + compileJava { - sourceCompatibility = '8' - targetCompatibility = '8' + if (javaToolchain != "8") { + options.release = 8 + } options.compilerArgs.add('-Xlint') } compileTestJava { - sourceCompatibility = '8' - targetCompatibility = '8' + if (javaToolchain != "8") { + options.release = 8 + } options.compilerArgs.add('-Xlint') }