d

    dimsuz

    2 years ago
    Hi! How to do this
    jvm {
            compilations.main.kotlinOptions { 
                jvmTarget = "1.8"
            }
        }
    for android? it works for jvm, but on android target I get:
    Could not get unknown property 'main' for KotlinJvmAndroidCompilation container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.
    during gradle sync
    Kris Wong

    Kris Wong

    2 years ago
    tasks.withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
    }
    d

    dimsuz

    2 years ago
    Sigh. I hoped this is more in line with how it's done on jvm. Why such assymmetry?...
    Kris Wong

    Kris Wong

    2 years ago
    i also do it this way with JVM
    d

    dimsuz

    2 years ago
    got it. will try this way, we have it like this on non-kmp android, but I thought here it's a bit different, because this is what recommended in official docs (for jvm, nothing for android).
    Kris Wong

    Kris Wong

    2 years ago
    they do the same thing. the snippet I pasted handles all KotlinCompile tasks, the one you pasted handles just one
    android.compilations["main"].kotlinOptions.jvmTarget = "1.8"
    or something similar would probably also work
    d

    dimsuz

    2 years ago
    that's exactly what I've thought too and what I've tried. See my top post, this gives me an exception 🙂
    that's what has surprised me. it's not the same for android compilation for some reason
    Kris Wong

    Kris Wong

    2 years ago
    what I've written and what you've written are different
    you have compilations.main, I have compilations["main"]
    d

    dimsuz

    2 years ago
    hmmm. Somehow I thought that this translates to the same thing. Thanks, I'll try this one a bit later!
    Kris Wong

    Kris Wong

    2 years ago
    the first one requires an extension function