aleksey.tomin

    aleksey.tomin

    2 years ago
    I try to migrate my MP multi-module project to 1.4-RC The root module has no code. On
    ./gradlew tasks
    see error
    Please initialize at least one Kotlin target in 'my-project (:)'.
    What I need to do? On 1.3.72 all OK. --info and --debug doesn’t help me. macOS, KMP contains OSX/minGW/android code gradle 6.4, 6.5.1 or 6.6, jdk - 1.8 or 11 - result the same PS: Solved - just add into root
    build.gradle.kts
    kotlin {
        jvm()
    }
    Thanks for @msink
    gildor

    gildor

    2 years ago
    Looks that you apply kotlin mpp plugin in your root project, but didn’t configure any targets there
    m

    msink

    2 years ago
    I had same error - in my project
    samples
    directory does'nt contain any code, all code is in subdirectories. So as workaround just added dummy
    kotlin {
        jvm()
    }
    block in
    samples/build.gradle.kts
    .
    gildor

    gildor

    2 years ago
    but why this module even applies kotlin mpp plugin if it doesn’t have sources. If it just a root project which doesn’t build anything itself it usually shouldn’t apply any plugins
    aleksey.tomin

    aleksey.tomin

    2 years ago
    @msink thank you, it works!
    gildor

    gildor

    2 years ago
    Yep, as I thought, you are applying mpp plugin to root module, even tho you don't have any code there or config, do not apply it to avoid warning (which correctly warns you that it's misconfigured)
    m

    msink

    2 years ago
    Or apply it in root module like this:
    kotlin("multiplatform") version "1.4.0-rc" apply false
    But my situation in
    kotlin-libui
    is a little different: in root
    build.gradle.kts
    I have
    kotlin("multiplatform") version Kotlin.version apply false
    ,
    in settings.gradle.kts:
    include(":libui")
    include(":samples:controlgallery")
    include(":samples:datetime")
    include(":samples:drawtext")
    include(":samples:form")
    include(":samples:hello")
    include(":samples:hello-ktx")
    include(":samples:histogram")
    include(":samples:logo")
    include(":samples:table")
    include(":samples:timer")
    (
    :samples
    itself even not included)
    And without that worksround - error
    Please initialize at least one Kotlin target in 'samples (:samples)'
    gildor

    gildor

    2 years ago
    @msink but you do apply multiplatform in
    samples
    , which is not used there, but used by subprojects. I understand why you are doing this, to make Gradle generate accessors so you could apply configuration in subprojects One way to do that is do not apply plugin to project itself, and instead use dynamic syntax to access extension
    m

    msink

    2 years ago
    Thanks 😁
    nrobi

    nrobi

    1 year ago
    I have the same issue when updating to AS
    4.2.0-alpha15
    , but I’m not applying the kotlin mpp plugin in the root
    build.gradle.kts
    @gildor am I missing something? 🤔
    gildor

    gildor

    1 year ago
    maybe you have some other code in another module which applies it
    nobody prevent other module call allprojects{} from any other module
    you can try to add observer for plugins and crash if plugin is applied to root module
    Also, you may have the same problem with any other module, not only root
    nrobi

    nrobi

    1 year ago
    It seems that updating gradle from
    6.7-rc-4
    to
    6.7
    solves the issue