Is there a way to locally publish a multiplatform ...
# multiplatform
m
Is there a way to locally publish a multiplatform library for Android only? I have a multiplatform lib that targets Android and JVM, but I only want to build for one target at a time to speed up builds. I cannot find a Gradle task that does what I want here.
publish
outputs
lib
,
lib-android
,
lib-android-debug
and
lib-jvm
. This works, but in this case I only need the Android outputs. I can publish
lib
and
lib-android-debug
individually with
publishKotlinMultiplatformPublicationToMavenLocal
and
publishAndroidPublicationToMavenLocal
, but then downstream modules complain that they cannot resolve
lib-android
. How do I publish
lib-android
correctly?
m
Not the answer you’re looking for but I try to only publish a single variant of Android libraries, I find it very confusing to have several variants
Copy code
kotlin {
    androidTarget {
        publishLibraryVariants("release")
    }
}
m
In my case I am using debug builds for development because they compile a lot faster and use release builds in the CI pipeline that compiles the final app only. I got around this problem for local builds so far by publishing everything once and then only rebuilding the Android debug variant. The issue is that CI uses clean builds and those are unnecessarily slow because they need to build all targets right now, and I expect this will only get worse once I add iOS support. That's why I am asking if I can only build the necessary Android artifacts.
m
Building your lib in release mode should be more or less the same speed as in debug. I don’t think R8 is enabled on libs by default? If it is you should definitely disable it. R8 is useful to build the final binary (app), not the libs
m
Hmm, I haven't actually timed it before so maybe the difference isn't actually that large. I was kind of just assuming since in most languages debug builds are a lot faster.
m
It’s mostly the same on Android IIRC, debug vs release is mainly a manifest flag + R8
In all cases, you can use your release lib for both your debug and release apps (unless you have specific code or resources but this is what I find confusing)
m
Alright, I'll give that a try. Thanks!