https://kotlinlang.org logo
Title
s

s3rius

02/19/2023, 1:40 PM
Hey, so I have a fairly regular project with
shared
,
app-android
and
app-desktop
modules. Is there any general consensus what is supposed to go into the
androidMain
source-set of
shared
vs what goes into
app-android
directly? My thoughts right now: • Permission-handling logic: that might live in androidMain actually • Anything that needs android-specific plugins like google-services probably won't work well outside app-main? • Does it make sense to puts things into `shared`'s manifest file if used inside
androidMain
? I assume
shared
is basically treated as a library, so manifests should be merged. Right now I'm trying to stuff everything into
shared
and
app-android
and
app-desktop
are mostly just for bootstrapping the application.
b

Big Chungus

02/19/2023, 2:36 PM
Shared should only have code in commonMain with the exception of actual declarations in target sourcets. Everything you cannot put in common main goes to app modules
just my opinion
c

Casey Brooks

02/20/2023, 3:28 PM
Yeah, I’d generally agree with Martynas, the common modules should ideally be as “common” as possible. Think of them like a bunch of libraries for your application, where they’re fairly loosely coupled and don’t get bound directly together yet. The app module, then, wires everything up via DI and gets it connected to the actual platform. So the app modules have no logic, but basically just connect all the pieces together. The shared modules are not pieced together, but have all logic.
So to your specific structure, unless you plan on developing multiple Android apps and multiple Desktop apps, I’d drop the
app-android
and
app-desktop
modules and move that stuff directly into your application modules. I think they will just be confusing you more than actually helping
b

Big Chungus

02/20/2023, 3:33 PM
I think op uses app-* modules as end consumers (i.e. actual apps rather than "libs meant for apps") so I don't think dropping them is an option. Or did you mean using jvmMain and androidMain sourceSets to build app bundles from within shared module itself?
c

Casey Brooks

02/20/2023, 3:36 PM
Ah, yeah, I think you’re right. Ignore that previous comment, then.
s

s3rius

02/20/2023, 8:29 PM
Thanks for your input 👍
P.S. Yeah, those two modules are to build the actual runnable applications