My release workflow is to gradle publish a MP libr...
# multiplatform
a
My release workflow is to gradle publish a MP library first on macos then on linux. On linux I'd get a warning about skipping mac and ios architectures since builds are not supported on linux. Not a problem because the maven publication would not wipe out the metadata of my prior publish on macos so it all worked fine. Changes within the last few weeks (and I have not touched my gradle files except bumping some dependencies) have caused my library to suddenly try to build ios and macos on linux (and fail). If I remove those platforms in my gradle.kts then publishing on linux wipes out the maven metadata for macos/ios, so that does not work. Does anyone have any idea what changed to suddenly cause this problem and/or how to tell gradle/maven that an architecture exists (so don't remove it) but don't actually try to build/publish it?
t
If your library is not using custom cinterops, you should be able to publish everything on non-Mac host by enabling cross-compilation: https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-publish-lib-setup.html#compilation-for-apple-targets
otherwise it is advisable to publish all from Mac host
a
This library has significant native sublibraries that need to be built with a c++ compiler so I would rather not figure out (having already done so for macos natively) or trust cross compilation results from linux to mac. And vice versa WRT publishing all from the mac host (and additionally my main development platform is linux). I'm not sure why this suddenly stopped working automatically, but I was able to discover a solution, which I'll include in case anyone else hits this. On Linux I define all the MP targets in the kotlin block -- this makes maven publishing aware they exist -- but then I disable any task whose name contains Ios or Macos:
Copy code
val MAC = System.getProperty("os.name").lowercase().contains("mac")
tasks.configureEach {
    if (!MAC && (name.contains("Ios") || (name.contains("Macos"))))
    {
        println("Not running on macos, so skipping $name")
        enabled = false
    }
}