https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

louiscad

02/27/2019, 6:23 AM
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:
Copy code
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)
d

Dico

02/27/2019, 6:46 AM
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]

02/27/2019, 8:20 AM
Original issue (fixed in 1.3.30): https://youtrack.jetbrains.com/issue/KT-29758
👌 1
r

ribesg

02/27/2019, 9:11 AM
@louiscad TL;DR rollback to Gradle 5.1.1 and it works, had the same issue
👍 1
l

louiscad

02/27/2019, 9:13 AM
@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
d

Dico

02/27/2019, 5:06 PM
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:
Copy code
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
l

louiscad

02/27/2019, 5:37 PM
@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.
d

Dico

02/27/2019, 5:38 PM
Oh, so then it doesn't force the configuration to be resolved?
l

louiscad

02/27/2019, 5:40 PM
Yes, it adds your lambda to be executed for all elements currently inside, and ones that'll be added later.
d

Dico

02/27/2019, 5:41 PM
Awesome, thanks a bunch
l

louiscad

02/27/2019, 5:41 PM
matching
creates a filtered subset of that gradle domain collection.
d

Dico

02/27/2019, 5:41 PM
gradle just became a little bit less shit
l

louiscad

02/27/2019, 5:42 PM
Yes, I'm glad this Slack and helpful users exists, I'd been harder otherwise.
d

Dico

02/27/2019, 5:42 PM
🙏
K
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
?
l

louiscad

02/27/2019, 7:47 PM
@Dico Nope, they are member functions of something like DomainObjectCollection<T>, as in
sourceSets
.
d

Dico

02/27/2019, 7:48 PM
Well, in this particular case it doesn't help then.
Since I have the configuration. Still, thanks