I want to publish small library that could be used...
# multiplatform
m
I want to publish small library that could be used either in commonMain KMM project and android, implementation is basically single kotlin file with dependency for coroutines. I'm having a hard time configuring the artifacts correctly for the maven. Do you know any good examples on how to do it on github or somewhere else? What I've got right now is KMM project with library implementation in the shared module in commonMain and the maven publish in root gradle file. Gradle throws error if I throw out ios and android config from shared build.gradle, so I have to have something there. If I add
jvm()
then everything builds correctly but then when I try to use it in client app it throws an error that it can't find
my-artifact-jvm
in the dependencies. How to solve it? Here's my lib https://github.com/tomczyn/state-in-merge
should I maybe use normal android project and package it as jar? Could this be used in the commonMain in KMM? Official docs could use more examples on libs publishing
p
I don't see the maven publish or any other publish plugin in the library build.gradle file
m
p
Ahh I see it now, and what is the specific problem
m
thanks for the links! I will check them out. The problem is not with uploading to maven, that works. I'm not sure how to package the artifacts, it doesn't seem to work either in KMM or Android
p
In Android you need to specify the publish variant
Copy code
android { 
         publishLibraryVariants("release"/*, "debug"*/) 
}
For KMM, I believe the process is a bit different if you want an xcframework. You probably need to host it in a swift package repo. I have been able to use the artifacts from a compose multiplatform project, the iOS target, using maven. But I haven't tried to consume from a pure swift project, I think it won't work.