this may be a silly question, but im confused abou...
# compose-desktop
a
this may be a silly question, but im confused about creating a multi-module application from the compose desktop starter project. i know how to add a module on android, but here it seems that the base module is top level. the jvmMain and jvmTest directories (i dont know whether to also consider them modules or not) dont have their own build.gradle file where i would add things like
implementation(path: ':common')
e
jvmMain and jvmTest are not modules, they are source sets
similar to how a pure Android project will have main, test, androidTest, debug, debugTest, debugAndroidTest, release, releaseTest… source sets
a
ooh
fascinating
so then adding more seems like its only mostly relevant for multiple platforms?
e
if none of your code is platform-specific, then it would be expected that you only need commonMain and commonTest
a
makes sense 👍 although this begs the question for me of how to actually implement modularisation in a project like this
as ive implied, i only know how to do anything of the sort when working on android projects. i dont even know what to google to get a primer on the matter
actually there's a question, what do i call this kind of desktop jvm development, in a way that will bring up relevant info on google?
e
it really isn't that different from Android's variants
in the Android world, by default you have
Copy code
:lib
    src/main
    src/debug
    src/release
:app
    src/main
    src/debug
    src/release
:lib
produces two variants,
debug
(which includes code from both
src/main
and
src/debug
) and
release
(which includes code from both
src/main
and
src/release
). in
:app
, code in
src/main
can use code in `:lib`'s
src/main
, code in
src/debug
can use code in `:lib`'s
src/main
and
src/debug
, and code in
src/release
can use code in `:lib`'s
src/main
and
src/release
. (there's some boundaries here that aren't as well enforced as KMP but that's basically the idea)
similarly, in your multiplatform setup, you can have
Copy code
:lib
    src/commonMain
    src/jvmMain
:app
    src/commonMain
    src/jvmMain
with the
jvm
platform containing code in both
src/commonMain
and
src/jvmMain
, and matching across module dependencies
within a single project (module) there are dependencies within source sets, but that doesn't matter outside of the project
a
this tracks, the only issue im seeing from my end is that, directory wise, things are laid out like
Copy code
root-project
    :lib
        src/commonMain
        src/jvmMain
    :app
        src/commonMain
        src/jvmMain
this makes sense to me, but the default compose multiplatform project looks more like
Copy code
:root-project
    src/commonMain
    src/jvmMain
so the root build.gradle is bot a "root project" gradle file and a module one. and in IDEA, when you add another module it is created in parallel, like
Copy code
:root-project
    src/commonMain
    src/jvmMain
:module
    etc
e
so, you can create subprojects just fine even if there's code within the root project
a
and they dont seem to link up together like how id expect
e
but if you want to modularize it, I would move things from the root project into a subproject
it works even if you don't, though.
a
yes, thats the impression i was beginning to get from our discussion: just move things around until they look like how id expect. if i want to.
e
you'll just have
Copy code
:
    src/...
:lib
    src/...
a
this is also my first project with kotlin gradle files, so its a bit of a double culture shock
nothing i cant handle though (i think :p) thanks for your help!