Sargun Vohra
08/04/2025, 6:24 PMlibrary-x.y.z-natives_os_arch.jar
. The user of the library would depend on the library (without classifier) plus one or more natives , depending on which platforms they support.
• I could publish all the native binaries outside of Maven Central, and document for the user how to add them to their app. But this seems hard to use, essentially introducing some nonstandard dependency management. Or, I could publish a small gradle plugin that configures this for the user.
• I could publish my library as a single fat jar with all six binaries included. But that feels like it unnecessarily inflates the binary size. And building this one jar in CI would get complicated, with build steps on multiple different runners all coalescing into one jar.
How is this typically done in the JVM and the KMP world?
For example, I assume Compose Multiplatform itself includes some native libraries (skia?). But as a user I don't have to do anything special to depend on it, perhaps because the Compose gradle plugin deals with it for me? Are there some good examples out there that don't come with an associated plugin?
The second approach (classifiers) seems like the most viable to me. But I'm unclear on:
• What would the gradle config look like for such a library?
• What would the configuration look like for the user of the library?
• Would they be able to use a version catalog with these special artifacts?
My goal with this KMP library is to support Kotlin/JVM and Android with JNI, and Kotlin/Native with cinterop. But for now, I'm focusing on the (non-android) JVM build only.ephemient
08/04/2025, 10:54 PMSargun Vohra
08/04/2025, 11:01 PMephemient
08/04/2025, 11:03 PMephemient
08/04/2025, 11:04 PMephemient
08/04/2025, 11:05 PMcompose.desktop.currentOs
dependency annoyingly conflates the building and target platform…)Sargun Vohra
08/04/2025, 11:05 PMSargun Vohra
08/04/2025, 11:07 PMephemient
08/04/2025, 11:08 PMephemient
08/04/2025, 11:08 PMSargun Vohra
08/04/2025, 11:09 PMephemient
08/04/2025, 11:09 PMephemient
08/04/2025, 11:10 PMSargun Vohra
08/04/2025, 11:11 PMactual typealias
on the JVM target to still export a common api with its native target. But it's probably viable. But it results in an extra maven artifactSargun Vohra
08/04/2025, 11:12 PMephemient
08/04/2025, 11:14 PMMy KMP module would then need a bunch ofsorry, maybe I didn't explain it well. I was thinking you could make a JVM project, whose only job is to wrap the `.so`/`.dll` artifacts into variant JARs. then depend on that from the JVM target of your KMP module, where all the normal Kotlin code would resideon the JVM target to still export a common api with its native targetactual typealias
Sargun Vohra
08/04/2025, 11:14 PMSargun Vohra
08/04/2025, 11:16 PMephemient
08/04/2025, 11:16 PMSargun Vohra
08/04/2025, 11:19 PMephemient
08/04/2025, 11:21 PMSargun Vohra
08/04/2025, 11:22 PMSargun Vohra
08/04/2025, 11:22 PMephemient
08/04/2025, 11:22 PMephemient
08/04/2025, 11:24 PMephemient
08/04/2025, 11:25 PMSargun Vohra
08/04/2025, 11:26 PMSargun Vohra
08/04/2025, 11:27 PMSargun Vohra
08/04/2025, 11:29 PMyeah Skiko does, and that makes a universal binary impossible (without custom tooling)That's interesting. For macOS I think I can build a universal dylib at least for my library. It'll double the size but that's probably fine, at least it's not 6x.
Sargun Vohra
08/04/2025, 11:30 PMSargun Vohra
08/04/2025, 11:35 PMephemient
08/04/2025, 11:36 PMSargun Vohra
08/04/2025, 11:40 PMVampire
08/05/2025, 8:57 AMurl
or download-url
or how the artifact is called to point to the artifacts of that other coordinates. This also improves consumability for non-Gradle consumers as those could depend on the specific variant by coordinates, while Gradle users can just use the "main" coordinates and use for example OperatingSystem
and MachineArchitecture
attribues to select the variant(s) they need.ephemient
08/05/2025, 9:08 AM