Hey :wave: I’m migrating from Gradle 6.x to 7.x an...
# android
a
Hey 👋 I’m migrating from Gradle 6.x to 7.x and from Android Gradle Plugin 4.x to 7.x so I’m trying to configure Java 11 target in my Gradle setup (following this description). My setup involves using some helper functions in
buildSrc
directory so I’m skipping that part. In the end, what I’m calling (or at least I should be calling) is simply:
Copy code
android {
    val javaVersion: JavaVersion = JavaVersion.VERSION_11

    compileOptions {
        sourceCompatibility = javaVersion
        targetCompatibility = javaVersion
    }

    kotlinOptions {
        jvmTarget = javaVersion.toString()
    }
}
Nevertheless, I’m still seeing a lot of build warnings:
Copy code
'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
Does anyone have any idea if I’m doing something wrong?
OK, I guess I figured it out. Turns out I forgot to configure the plain Kotlin Gradle modules (so non-Android ones). I ended up configuring it in a single place using
Copy code
allprojects {
    tasks.withType(type = org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) {
        kotlinOptions {
            jvmTarget = javaVersion.toString()
        }
    }
}
and it seems to be working well because the warnings disappeared.