Thread
#multiplatform
    louiscad

    louiscad

    3 years ago
    Did anyone succeed in publishing a multiplatform library using Gradle 5.2.1 and Kotlin 1.3.21? I'm consistently getting the following error:
    Execution failed for task ':modules:name-of-my-module:generateMetadataFileForJvmPublication'.
    > org.jetbrains.kotlin.gradle.plugin.mpp.HierarchyAttributeContainer cannot be cast to org.gradle.api.internal.attributes.AttributeContainerInternal
    (I also reported it here: https://youtrack.jetbrains.com/issue/KT-30158?project=kt)
    Dico

    Dico

    3 years ago
    I'm kinda hanging on to 4.10.3 myself. How do you even make it work in 5.1.1? For me it complains because I'm accessing unresolved configurations or something ..
    a

    Alexey Belkov [JB]

    3 years ago
    Original issue (fixed in 1.3.30): https://youtrack.jetbrains.com/issue/KT-29758
    r

    ribesg

    3 years ago
    @louiscad TL;DR rollback to Gradle 5.1.1 and it works, had the same issue
    louiscad

    louiscad

    3 years ago
    @Dico Look at the linked repo in my issue I linked in this thread, it works with 5.1.1 which I downgraded to until Kotlin 1.3.30
    Dico

    Dico

    3 years ago
    That's a very nice set of libraries @louiscad When I convert my project from 4.10.3 to 5.1.1, I get this problem:
    Cannot change attributes of configuration ':capture-age:nativeApiElements' after it has been resolved
    Which is caused by these lines when configuring a
    Jar
    task to create a fat Jar:
    for (file in configurations["jvmMainImplementation"]) {
        
    }
    Obviously, this wouldn't do anything. I'm just demonstrating that looping over the files causes the problem. Normally it would say something like "configuration jvmMainImplementation is not resolved" or something such, which is annoying, but I don't know what my native target has to do with this.
    I think it may be caused by this loop over the files "resolving" the nativeApiElements configuration, which is problematic when an
    afterEvaluate
    block inserted by the MPP plugin runs.
    It seems to work if I wrap this in an
    afterEvaluate
    block, so I guess that solves it for now.
    Also looks like you need to
    dependsOn
    metadataJar
    louiscad

    louiscad

    3 years ago
    @Dico You can use
    all { …}
    for
    .gradle.kts
    files,
    all(Action { this.something })
    in buildSrc's
    .kt
    files, and
    matching
    in both to handle things that can be added later in gradle's domain collections.
    Dico

    Dico

    3 years ago
    Oh, so then it doesn't force the configuration to be resolved?
    louiscad

    louiscad

    3 years ago
    Yes, it adds your lambda to be executed for all elements currently inside, and ones that'll be added later.
    Dico

    Dico

    3 years ago
    Awesome, thanks a bunch
    louiscad

    louiscad

    3 years ago
    matching
    creates a filtered subset of that gradle domain collection.
    Dico

    Dico

    3 years ago
    gradle just became a little bit less shit
    louiscad

    louiscad

    3 years ago
    Yes, I'm glad this Slack and helpful users exists, I'd been harder otherwise.
    Dico

    Dico

    3 years ago
    :tnx:
    :kotlin-flag:
    Is it just me or is gradle 5.1.1 significantly faster than 4.10.3
    I can find neither of those functions: all, matching
    are they instance functions of
    Configuration
    ?
    louiscad

    louiscad

    3 years ago
    @Dico Nope, they are member functions of something like DomainObjectCollection<T>, as in
    sourceSets
    .
    Dico

    Dico

    3 years ago
    Well, in this particular case it doesn't help then.
    Since I have the configuration. Still, thanks