icerockdev / moko-parcelize

@Parcelize support for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
65 stars 2 forks source link

Feature/support all kotlin targets #14

Closed nrobi144 closed 3 years ago

nrobi144 commented 3 years ago

@Alex009 , yepp, unfortunately I didn't find a way to avoid explicitly configuring every sourceSet Any ideas?

Alex009 commented 3 years ago

@nrobi144 i think we can use all with name.startWith:

val nonAndroidPrefixes = listOf("ios", "macos", "linux", ...)
sourceSets.matching { sourceSet ->
    nonAndroidPrefixes.any { sourceSet.name.startWith(it) }
 }.all {
  ...
}
nrobi144 commented 3 years ago

@nrobi144 i think we can use all with name.startWith:

val nonAndroidPrefixes = listOf("ios", "macos", "linux", ...)
sourceSets.matching { sourceSet ->
    nonAndroidPrefixes.any { sourceSet.name.startWith(it) }
 }.all {
  ...
}

(@Alex009 that's right, but I was thinking of reusing the created targets. For ex the ios(), windows() & linux() could return a listOf<KotlinNativeTarget>, would be cool to tie the configuration to that list)

nvm, looks like this does the job

val intermediateSourceSets = listOf(commonMain, notAndroidMain)
        matching { sourceSet ->
            !sourceSet.name.startsWith("android") && sourceSet !in intermediateSourceSets
        }.all {
            dependsOn(notAndroidMain)
        }