I have KMP project with android and ios targets, I...
# multiplatform
f
I have KMP project with android and ios targets, I want to add wasmJs, but Room is in commonMain. Any ideas on how to extract out the room database and only apply it to android/ios targets?
j
You can make your own groups that encapsulate other groups like this: https://github.com/JakeWharton/mosaic/blob/trunk/mosaic-runtime/build.gradle#L8-L17
So you'd do a "mobile" that contained "android" and "ios", and then move the dependency to mobileMain sourceSet declaration
And move your code that talks to it to src/mobileMain/kotlin/
That DSL works better in kts. I filed an issue to fix it for Groovy
f
Thanks Jake will have a crack at it today!
Ended up going with this, works great :)
val mobileMain = create("mobileMain") {
kotlin.srcDir("src/mobileMain/kotlin")
dependsOn(commonMain)
dependencies {
implementation(libs.androidx.data.store.core)
implementation(libs.androidx.room.runtime)
}
}
val androidMain by getting {
dependsOn(mobileMain)
....
val iosMain by getting {
dependsOn(mobileMain)
j
Yeah that's the old, manual API that the hierarchy template was created to replace
f
Ah ok, I'll take a look and see if I can update to what you did in mosaic.