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

Sam

12/03/2018, 6:23 PM
Is there a workaround for https://youtrack.jetbrains.com/issue/KT-27535 ? I know there are some libraries out there publishing Android aar artifacts.
h

h0tk3y

12/03/2018, 7:24 PM
Until the issue is fixed, you can setup AAR publishing in a multiplatform project in the same way you would for a simple Android library. As reflected in the issue, if you publish a multiplatform library with Gradle module metadata, the Android part won't be added to the metadata. But you can publish it separately under its own Maven coordinates, which should work fine for most use cases.
I believe the widely used solutions for publishing AAR's to Maven repos are all third-party Gradle plugins.
r

russhwolf

12/03/2018, 8:09 PM
Somehow I was never able to get it working manually, but I haven't tried since KotlinConf so I don't remember what I was getting stuck on. I'll have to dig back into it at some point.
s

Sam

12/03/2018, 9:36 PM
Yes you do because I used some of your Gradle code as help in getting as far as I have. 😀
h

h0tk3y

12/04/2018, 3:15 PM
Well, the
digital.wup.android-maven-publish
plugin indeed doesn't seem to work well in a multiplatform project. I could, however, make it publish my AAR from a sample MPP as follows:
Copy code
apply plugin: 'digital.wup.android-maven-publish'

publishing {
    publications {
        mavenAar(MavenPublication) {
            artifactId = project.name + "-" + kotlin.targets.androidLib.name.toLowerCase()
            from components.android
            artifacts.removeAll(artifacts.matching { !it.file.name.endsWith('aar') })
        }
    }
}
The artifacts part removes the JARs built for the other platforms that the plugin adds to the publication for some reason.
j

Jonas Bark

12/04/2018, 8:00 PM
@h0tk3y is that sample mpp app public by any chance? 🙂
h

h0tk3y

12/04/2018, 8:01 PM
This one: https://github.com/h0tk3y/k-new-mpp-samples/tree/master/android-lib-and-app-with-mpp (doesn't include the changes I described above, and it's a bit outdated, it was a pre 1.3.0 experiment, it never got updated past 1.3-RC)
🙏 1