Source set 'commonMain' of project '<project name>' is part of several compilations [debug, release, main]
ScottPierce opened this issue ยท 5 comments
I added the kotlinx-atomicfu
plugin to my multiplatform project. As soon as I did that I get the following error:
Source set 'commonMain' of project '<project name>' is part of several compilations [debug, release, main]
Here is my entire build.gradle.kts
:
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.multiplatform")
id("kotlinx-atomicfu")
}
android {
compileSdkVersion(AndroidConfig.compileSdkVersion)
defaultConfig {
minSdkVersion(AndroidConfig.minSdkVersion)
targetSdkVersion(AndroidConfig.targetSdkVersion)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation(Libs.kotlin.stdlib.jvm)
implementation(Libs.androidx.annotation)
implementation(Libs.androidx.browser)
implementation(Libs.rally.kinject.jvm)
implementation(Libs.rally.kinject.jvm)
implementation(Libs.kotlinx.coroutines.android)
}
kotlin {
android()
@Suppress("UNUSED_VARIABLE")
sourceSets {
val commonMain by getting {
dependencies {
implementation(Libs.kotlin.stdlib.common)
implementation(Libs.rally.kinject.common)
implementation(Libs.rally.store.common)
implementation(Libs.rally.disposable.common)
implementation(Libs.kotlinx.coroutines.common)
}
}
val commonTest by getting {
dependencies {
for (lib in Libs.kotlin.test.common) {
implementation(lib)
}
}
}
}
}
I encountered the same issue when I tried to add atomicfu plugin to a multiplatform library (android and iOS).
Source set 'commonTest' of project 'picross-client-core' is part of several compilations [debugAndroidTest, debugUnitTest, releaseUnitTest, test]
It does looks like a bad interaction between atomicfu plugin and android plugin that adds one test source sets by flavor.
Any thought on how to avoid this?
I found that the bad interaction must be with the android()
target. I have other targets (ios()
), if I remove andoid()
then Gradle sync will succeed, alternatively if I keep android()
and remove kotlinx-atomicfu
plugin then Gradle sync will succeed.
Did either of you find a solution to this? Is it impossible to use kotlinx-atomicfu
now?
I'm now experiencing this all over again on a new project. I'm a little confused that this hasn't been addressed in the 5 months since I filed the bug. This isn't an edge case, it's supposed to be the supported path for this library.
I didn't find a solution. I'm still using atomicfu, I'm just not using the gradle plugin for it. Just the runtime.
it's supposed to be the supported path for this library.
atomicfu
is more or less experimental and was always developed for our own needs, not for public use.
This problem comes from the fact that kotlin-android
plugin is not supported and we don't have plans to do so in an observable future because we have other (more important) work to do.
But we are ready to accept a high-quality contribution (one that does not require five iterations of code review and written in a manner similar to how existing code is written).
Encountered the same issue