https://kotlinlang.org logo
l

Landry Norris

02/24/2022, 4:36 PM
I’m planning on starting a project soon that will require server, desktop, cli, and maybe mobile or web, and I’d like to make it entirely in Kotlin Multiplatform. The current plan is to make a monorepo, but I’m wondering if it would be better to set it up as separate projects inside of a folder or use several modules in one project, with a module for shared code, and a module for each platform. My primary concern is that I’ll need to be able to deploy each platform (desktop, server, mobile) separately once I get that far. What is the suggested setup for something like this?
m

mbonnin

02/24/2022, 4:37 PM
I'd vote for single git repo + multiple gradle modules
4
Being able to share code between your backend and frontend is super nice
You can always deploy individual modules separately
l

Landry Norris

02/24/2022, 4:39 PM
I was leaning towards modules. How is deployment when doing this? Does config get annoying?
m

mbonnin

02/24/2022, 4:40 PM
It depends your workflow but I wouldn't expect anything to be too complicated
Worst case you have to call
./gradlew :backend:deploy
instead of
./gradlew deploy
nothing good CI/script can handle
l

Landry Norris

02/24/2022, 4:41 PM
Since I'll be using Compose for UI, which requires a specific kotlin version, is there a good way to use newest kotlin for server/cli and a different version for desktop/mobile?
m

mbonnin

02/24/2022, 4:45 PM
Ouch, I know nothing about that but that does sound like it could complicate things....
I'd hope you can use the Compose version of Kotlin for all the rest and that in a couple of months everything becomes streamlined
l

Landry Norris

02/24/2022, 4:46 PM
I can look into it. It’s not a dealbreaker if the Kotlin version has to be the same for the platforms.
Thank you. I think I’ll look into setting up one project with different modules. I once set up a project with one git repo that had two separate gradle projects in separate folders, but keeping models in sync got a bit annoying.
e

ephemient

02/24/2022, 4:47 PM
it is possible to use different kotlin versions in different included builds, and compose a larger build out of that
m

mbonnin

02/24/2022, 4:49 PM
So composite builds instead of multiple modules?
I think I'd still try to use the same Kotlin version everywhere, sounds easier to manage and I've had some issues with IDEA + included builds
e

ephemient

02/24/2022, 4:50 PM
personally, I'd split into as few composite builds as possible, because there are still some annoyances across them (e.g.
./gradlew test
runs all tasks named
test
in the build, but not included builds)
1
m

mbonnin

02/24/2022, 4:51 PM
Yea, running tests from included builds from IDEA is also another thing that isn't super reliable
e

ephemient

02/24/2022, 4:51 PM
if you can get away with a single kotlin version for all your modules, all the better. but if not, it is possible to work around
👍 2
well, you can run
:includedBuild:test
without any issues, it just doesn't happen when you run an unqualified
test
m

mbonnin

02/24/2022, 4:52 PM
I'm talking in the UI + debugging
e

ephemient

02/24/2022, 4:52 PM
oh I never bother with the UI :)
😄 1
m

mbonnin

02/24/2022, 4:52 PM
I like clicking the green triangle and setting breakpoints with my mouse 🙂
e

ephemient

02/24/2022, 4:53 PM
IIRC if you tell IntelliJ to debug a Gradle task explicitly, it does work and you can set breakpoints
m

mbonnin

02/24/2022, 4:54 PM
Haven't tried recently maybe it's working now
2 Views