Trying to build and publish a library with the new...
# multiplatform
k
Trying to build and publish a library with the new mpp. I can get jvm6/8 and native ios builds to both compile and publish (seems correct but haven't tried to consume). Android library (aar) will build and the aar files wind up in the build folder's outputs section. When published, it'll create a folder for the android lib, but the aar isn't included. The other folders look different (they have jar and klib files). Thoughts? I can push the source later to take a look at it if that helps, but hoping there's a simpler answer (like "do this" or "that doesn't work yet").
I've tried to build the lib sample (https://github.com/h0tk3y/k-new-mpp-samples/tree/master/android-lib-and-app-with-mpp), but the build fails. Wondering if there's something subtle I'm missing before going down that particular rabbit hole.
Kotlin gradle plugin version is '1.3.0-dev-496'
OK, pushed. This is the Timber fork. Ignore most of the folders. The only project that gets built is the 'timber' folder. https://github.com/touchlab/timber/tree/newgradle
I made that config slightly less confusing. To try this out, clone that branch, run gradle build and publish. There's a property called 'localMavenDeploy' that I would normally configure externally, but put in gradle.properties for simplicity here.
l
Regarding to `aar`: unfortunately the publishing isn’t implemented yet, but it’s on the way. Most probably, it wouldn’t be included in Kotlin 1.3, but rather in some later versions. Nevertheless, I believe the AAR in the build directory is completely valid and eligible for use. You can try to publish them like this:
<https://stackoverflow.com/a/39252262/2196460>
or this:
<https://github.com/wupdigital/android-maven-publish>
Regarding to the example: indeed, it requires a small correction, I’ll try to push the fix soon, sorry for the inconvenience. Yet, the lib part from there isn’t supposed to be published: there is no such configuration like the one described here: https://github.com/h0tk3y/k-new-mpp-samples#publishing-and-mpp-library-dependencies. To try out the lib publishing with its consequent usage, you may take a look at this example: https://github.com/h0tk3y/k-new-mpp-samples/tree/master/lib-and-app. It doesn’t have Android target, but gives the main idea. And the latest note: the best plugin version to be used currently is the latest Kotlin 1.3-RC, which is
1.3.0-rc-57
. It is recommended to update the dependencies to have the latest fixes and updates for MPP as well. Also, don’t forget to specify EAP repo for it:
maven { url '<https://dl.bintray.com/kotlin/kotlin-eap>' }
k
Thanks for the reply. I was having trouble with mpp and digital.wup.android-maven-publish previously, but seem to be able to locally publish with that now.
Android and iOS libraries are our primary use case. Pretty much the only use case right now. Being able to publish them is obviously important. A functional example would be very useful I think. I am concerned that we'll run into issues on the aar side as libraries have transitive dependencies. I'm going to spend the next few hours trying to get this to work. See how it goes. May need to revisit after the conference, though.
l
Thank you for the feedback! You are more than welcome to ask more questions arising on the way. We are working on the functional example right now, its importance indeed clear enough. I’ll certainly let you know when it’s ready
k
I was able to publish to bintray and consume the aar in an android app directly, but haven't tried using the multiplatform dependency yet
l
Which way did you use to publish it?