https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

Rak

11/05/2021, 9:19 AM
Hi, I am investigating options for distributing versions of my KMM library to my existing apps. Regarding android, a lot of articles talk about using Maven, however isn’t that open to all? Most companies create closed source code. I assume in that case a solution like Nexus/Artifactory? Or does maven support private uploads?
b

Big Chungus

11/05/2021, 9:39 AM
If by maven you mean maven central then no. In itself it's just a public instance of nexus. You can spin up a free jfrog artifactory instance in the cloud to store your artifacts privately
Or just install your own nexus server on raspberry pi or something
r

Rak

11/05/2021, 9:47 AM
i work in a corporate environment so just adding servers is not easy.
b

Big Chungus

11/05/2021, 9:48 AM
Then go for a free artifactory cloud instance
r

Rak

11/05/2021, 9:48 AM
I was thinking maybe i could use CI. The KMM project generates a aar file and then I can pass it to the android project and have it commited into that repo
not thought it through yet!
b

Big Chungus

11/05/2021, 9:49 AM
Isn't this free tier sufficient for your needs?
r

Rak

11/05/2021, 9:50 AM
thats not really the point
b

Big Chungus

11/05/2021, 9:50 AM
Isn't it?
k

kqr

11/05/2021, 9:50 AM
in the end I think if company is hosting sources it should have its own artifact repository
r

Rak

11/05/2021, 9:50 AM
I would ahve to get approval to use thrird parties
I wonder if github has something similar
b

Big Chungus

11/05/2021, 9:51 AM
If you just need to transfer raw aar, any cloud storage solution will do. Even google drive is fine
r

Rak

11/05/2021, 9:52 AM
which is why i was thinking of using CI. It can host the arr file until i download to the apps
b

Big Chungus

11/05/2021, 9:52 AM
But if you want to make it available as a proper maven artifact, you'll need to put some extra work in. I've seen people using github repo as maven artifactory server as well
r

Rak

11/05/2021, 9:52 AM
“github repo as maven artifactory server” - any sources?
b

Big Chungus

11/05/2021, 9:53 AM
But aar file alone is not enough as you lose all your metadata (e.g. dependencies)
r

Rak

11/05/2021, 9:53 AM
what do you mean?
isnt the aar file “fat”?
b

Big Chungus

11/05/2021, 9:54 AM
Not for libs, for obvious reasons
r

Rak

11/05/2021, 9:55 AM
interesting, do you know if its possible to do something similar with gradle?
b

Big Chungus

11/05/2021, 9:58 AM
In short, you need to create a new repo and then declare it in your gradle as this
Copy code
repositories {
  maven("<https://rawgit.com/USERNAME/REPONAME/BRANCHNAME|https://rawgit.com/USERNAME/REPONAME/BRANCHNAME>") {
credentials (...)
}
}
Publish to it and declare it as source repo on another project
Gradle will take care of putting stuff in the right places
r

Rak

11/05/2021, 10:03 AM
now I am thinking the better approach is to create the kmm shared module inside my existing android app
then i have to work out what to do about iOS…
b

Big Chungus

11/05/2021, 10:04 AM
That's the recommended approach
Move ios to android repo as well
Keep everything in the monorepo
r

Rak

11/05/2021, 10:05 AM
thats not going to work
to much disruption
b

Big Chungus

11/05/2021, 10:05 AM
Alternatively, connect your kmm module to android or ios repos with git submodules
That way you can still keep three repos, but have them connected
r

Rak

11/05/2021, 10:06 AM
that might warrant investigation - though a few years ago i used git submodules and it was a nightmore
b

Big Chungus

11/05/2021, 10:06 AM
Tbh, I think the easiest solution for your case would be to just create that free artifactory instance and publish your kmm stuff there
r

Rak

11/05/2021, 10:07 AM
perhaps, but not a solution for iOS
b

Big Chungus

11/05/2021, 10:07 AM
You can push both, aar and pod to artifactory, both built from same kmm project
r

Rak

11/05/2021, 10:08 AM
i’ll definately mention that as a possible solution, thanks for your help, very much appreiciated
b

Big Chungus

11/05/2021, 10:08 AM
That way, both consumers can be oblivious about there even being kmm module. On consumer side it would be just consuming native libs
And artifactory is just one of the options for artifact repository server. You can do the same with nexus as well.
🙌 1
b

Big Chungus

11/05/2021, 10:59 AM
I found gh packages very hard to work with. Using regular gh git repo as maven repo is much easier.
h

hfhbd

11/05/2021, 11:00 AM
Why? It is a normal maven repo, only password protected.
b

Big Chungus

11/05/2021, 11:01 AM
Well it doesn't allow overriding stuff and has no staging mechanism, so if something goes wrong when publishing all mpp artefacts, you are left with either manually removing all partial artefacts or incrementing version before trying again
🙏 1
And i had occasional network errors when uploading from gh actions, which effectively invalidated my entire version, even if some artefacts did upload...
7 Views