Hello, I am planning out development of my project...
# gradle
g
Hello, I am planning out development of my project's idea. It will consist of desktop, android and server applications. I want to use some common code across these apps, i.e.: domain models, composables, etc. The issue is, that desktop and android are going to be different apps, so using typical structure for KMM apps (composeApp module containing androidMain, commonMain and desktopMain) doesn't seem like a great idea. So I tried using Gradle composite builds. I managed to include dependency from common composite build in android composite build by using
includeBuild(../common)
. But I also want to able build all composite builds from the root project, but in this approach I can't access the build task of these composite builds. I'd be grateful if someone would put me on the right track. I want to cleanly separate parts that are not related but also to be able to reuse some common code. I am open to completly different approach to this problem, suggestions are appreciated.
a
Hi, so to make it clear, you want to develop different UI code for different platforms (in this case, android and desktop) but also being able to share some code that is related?
g
Yes, but with one additional detail - android and desktop should be different apps for different purposes
a
I'm not sure I have fully understand your question, but you tried creating different modules, for desktop and android, and third module which can contain any shared code you want like the UI code or anything else and make the android and desktop depends on the shared module by using
implementation(project(":shared"))
or
common
and to configure Gradle to use this new module, create the older and add it in the
settings.gradle.kts
by using
include(":shared")
or
common
(the name could be anything you want) You seems to already know all of this, so I haven't understand the problem
g
Thanks, it's really that simple. Sometimes I get stuck on some idea being bad and I just stop considering it and try to dig deeper instead of turning back. Thanks for help, fresh perspective helps.
a
Happen with all of us, you're welcome.