https://kotlinlang.org logo
#ktor
Title
# ktor
m

michaelv

03/18/2021, 9:22 AM
Hi ktor community. All the ktor tutorials on the kotlin site seem to have everything in one project. Is it possible to have separate projects and repositories for each part of a multiplatform app? E.g. 1 repo just for server, 1 for the shared logic, and 1 for each client that would have a dependency on the shared repo. It seems like it should be possible but I’m finding it very confusing to get running due to not finding any examples. E.g. where did the jvmJar build task come from in the sample app? Do we have to have one “god” repository or can we split it up? E.g. I only want to use android studio for the android client. I don’t want to see ios stuff in there. I want to build the shared code in intellij where it has nothing to do with android. and ios should be only in xcode with the shared framework as a dependency. Hope that makes sense. Not seeing anyone talking about doing it this way.
b

Big Chungus

03/18/2021, 9:53 AM
absolutely. Here's my setup doing almost exactly that (shared mpp module, jvm scanner module and jvm + js app module)
You still need to gave everything in one repo, but each part is now isolated in it's own submodule. Alternatively you can all that in separate repos and publish shared code artifacts to some maven repo to consume in your "app" repos
m

michaelv

03/19/2021, 7:35 AM
ok thanks but is there any examples of how to do this? I think if we were ever to use this at work it would need to be in separate git repositories not one huge repo with separate modules. I mean I would want to eventually have separate modules for each feature not entire apps. Just seems way too complex for a big app to be in one enormous repo for every platform and even the backend.
Ok I worked it out. For the serialisation part on the client I have to manually decode the Json (not really sure why but it works). So far just doing it in the kotlinjs one but should be the same in the other ones. E.g.
Copy code
Json.decodeFromString(jsonClient.get(endpoint + ShoppingListItem.path))
Anyway I’m unblocked for now so hopefully smooth sailing from here. Thanks for your response!
Actually I think maybe when I add in the shared repo which won’t be kotlinjs it might “just work”. Maybe it just doesn’t work properly from kotlinjs. I just started with that since that’s how the tutorial was done. Anyway it’s making more sense now. If I add in the shared repo none of the clients need to do this anyway as they’ll have direct access to the shared repo.