-
Notifications
You must be signed in to change notification settings - Fork 443
Open
Labels
blocked: AAChanges required in Analysis APIChanges required in Analysis APIbugtopic: K2Issues / PRs that are related to the K2 migration. See #2888Issues / PRs that are related to the K2 migration. See #2888upstream bugAn issue that appears due to an upstream dependency bug, such as kotlin-compilerAn issue that appears due to an upstream dependency bug, such as kotlin-compiler
Milestone
Description
Sometimes projects may use the same folder as source root in different modules. Like the same dir for several targets in KMP.
It can be done with such syntax:
kotlin {
sourceSets {
jsMain {
kotlin.srcDir('src/browserMain/kotlin')
}
wasmJsMain {
kotlin.srcDir('src/browserMain/kotlin')
}
}
}
Possible scenarios for that: Android and JVM source sets or Js and WasmJs. Sharing source sources for them using KMP hierarchies is just painful.
Projects that already use the pattern:
- https://github.com/cashapp/molecule/blob/34e57f70b1f7e7b08e9cd2ce6923e2f2b3be54b9/molecule-runtime/build.gradle#L77
- https://github.com/JakeWharton/mosaic/blob/eb76d4c1baf4605614f2346d081340c8d574320a/samples/counter/build.gradle#L18
- https://github.com/f-droid/fdroidclient/blob/d38b952e6dddef3d3baef9007e88d238e675be46/libs/download/build.gradle#L57
- https://github.com/GitLiveApp/firebase-kotlin-sdk/blob/1abbb9b64fb2c9e77aaee22f74a3fe9a2f548b7d/firebase-config/build.gradle.kts#L145
Kotlin with K2 works fine for them.
IJ with Kotlin K2 Analysis also works: it just uses one of the platforms for analysis. And report warning:
Path [/Users/Andrei.Tyrin/IdeaProjects/_external/molecule/molecule-runtime/src/browserMain/kotlin] of module [molecule.molecule-runtime.jsMain] was removed from modules [molecule.molecule-runtime.wasmJsMain]
Dokka at the same time has the special treatment for that (#3239):
Pre-generation validity check failed: Source sets 'android' and 'jvm' have the common source roots: /Users/Andrei.Tyrin/IdeaProjects/_gates/firebase-kotlin-sdk_mpp/firebase-config/src/androidMain/kotlin. Every Kotlin source file should belong to only one source set (module).
There is a ticket to forbid such setup in KGP: https://youtrack.jetbrains.com/issue/KT-62829/Add-a-check-that-two-source-sets-cannot-have-the-same-file-system-directory. But the priority is low.
Metadata
Metadata
Assignees
Labels
blocked: AAChanges required in Analysis APIChanges required in Analysis APIbugtopic: K2Issues / PRs that are related to the K2 migration. See #2888Issues / PRs that are related to the K2 migration. See #2888upstream bugAn issue that appears due to an upstream dependency bug, such as kotlin-compilerAn issue that appears due to an upstream dependency bug, such as kotlin-compiler