Did anyone succeed in publishing a multiplatform l...
# multiplatform
l
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
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
Original issue (fixed in 1.3.30): https://youtrack.jetbrains.com/issue/KT-29758
👌 1
r
@louiscad TL;DR rollback to Gradle 5.1.1 and it works, had the same issue
👍 1
l
@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
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
@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
Oh, so then it doesn't force the configuration to be resolved?
l
Yes, it adds your lambda to be executed for all elements currently inside, and ones that'll be added later.
d
Awesome, thanks a bunch
l
matching
creates a filtered subset of that gradle domain collection.
d
gradle just became a little bit less shit
l
Yes, I'm glad this Slack and helpful users exists, I'd been harder otherwise.
d
🙏
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
@Dico Nope, they are member functions of something like DomainObjectCollection<T>, as in
sourceSets
.
d
Well, in this particular case it doesn't help then.
Since I have the configuration. Still, thanks