https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
u

ursus

02/05/2023, 1:41 AM
Question, how come
import androidx.compose.foundation
ui
etc work in compose desktop? In my android project I tried to use those dependencies in a pure
kotlin
(jvm) module (just some extensions, no @Composable stuff), and gradle complained about the module not applying `kotlin-android`so I figured those have an android dependency? Or did I mess something up?
a

Albert Chang

02/05/2023, 2:50 AM
Compose for Desktop has its own artifacts that can be used in pure JVM modules.
u

ursus

02/05/2023, 2:52 AM
but how? when I click into say
MaterialTheme
class, its exactly the same is it just a copy? they take all of the android compose sources, and strip the android stuff, and publish?
a

Albert Chang

02/05/2023, 2:54 AM
Basically that, and delegate to Google version for Android.
u

ursus

02/05/2023, 2:54 AM
Tldr; if it were interfaces then I'd get it, they just provide desktop impl, but its whole concrete sources, so it must be a copy
okay understood, thanks!
which kind of makes me wonder why, must be very error prone process to update -- how come the android bits are not isolated, so just a different impl would be provided, so no need to copy stuff? must be bit more nuisanced
a

Albert Chang

02/05/2023, 3:02 AM
Sounds like you need to learn some basics of Kotlin multiplatform.
u

ursus

02/05/2023, 3:05 AM
that might be true, but looking at the dependency graph I'd expect there to be some androidx dependency, where the jetbrain dependecy provides the `actual`s but yea, I never actually built stuff with kmm
e

ephemient

02/05/2023, 5:40 AM
if you apply the org.jetbrains.compose gradle plugin, it'll give you a shortcut for the proper dependencies (e.g.
dependencies { implementation(compose.foundation) }
), substituting them as appropriate for Android
in general you should always use the plugin when working with compose multiplatform, https://github.com/JetBrains/compose-jb/issues/1404
u

ursus

02/05/2023, 12:07 PM
Yes but my question now is, say
MaterialTheme.kt
, is in both the jetbrains and in androidx package, is it 1) pulled in via som dependency (not visible in the graph 2) or is it a "copy paste"
7 Views