DEV Community

Query Filter
Query Filter

Posted on

docker118

// Explicitly wire the compiler to the task
tasks.withType(JavaCompile).configureEach {
    def targetVersion = project.hasProperty('useJava8') ? 8 : 21

    // This forces the task to look up the compiler from the toolchains Gradle found
    javaCompiler = javaToolchains.compilerFor {
        languageVersion = JavaLanguageVersion.of(targetVersion)
    }

    println "Task ${name} is using compiler version: ${targetVersion}"
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)