@@ -119,8 +119,15 @@ private fun String.sourceSetNameToType(): CompilationType? = when (this) {
119119private val Project .config: AtomicFUPluginExtension
120120 get() = extensions.findByName(EXTENSION_NAME ) as ? AtomicFUPluginExtension ? : AtomicFUPluginExtension (null )
121121
122- private fun getAtomicfuDependencyNotation (platform : Platform , version : String ): String =
123- " org.jetbrains.kotlinx:atomicfu${platform.suffix} :$version "
122+ private fun getAtomicfuDependencyNotation (platform : Platform , version : String ): String {
123+ val suffix = when (platform) {
124+ // in common source sets, use a dependency on the MPP root module:
125+ Platform .COMMON -> atomicfuRootMppModulePlatform.suffix
126+ else -> platform.suffix
127+ }
128+ return " org.jetbrains.kotlinx:atomicfu$suffix :$version "
129+ }
130+
124131
125132// Note "afterEvaluate" does nothing when the project is already in executed state, so we need
126133// a special check for this case
@@ -241,12 +248,14 @@ fun Project.sourceSetsByCompilation(): Map<KotlinSourceSet, List<KotlinCompilati
241248 return sourceSetsByCompilation
242249}
243250
251+ private val atomicfuRootMppModulePlatform = Platform .NATIVE
252+
244253fun Project.configureMultiplatformPluginDependencies (version : String ) {
245254 if (rootProject.findProperty(" kotlin.mpp.enableGranularSourceSetsMetadata" ).toString().toBoolean()) {
246255 val configurationName = project.extensions.getByType(KotlinMultiplatformExtension ::class .java).sourceSets
247256 .getByName(KotlinSourceSet .COMMON_MAIN_SOURCE_SET_NAME )
248257 .compileOnlyConfigurationName
249- dependencies.add(configurationName, getAtomicfuDependencyNotation(Platform . NATIVE , version))
258+ dependencies.add(configurationName, getAtomicfuDependencyNotation(atomicfuRootMppModulePlatform , version))
250259 } else {
251260 sourceSetsByCompilation().forEach { (sourceSet, compilations) ->
252261 val platformTypes = compilations.map { it.platformType }.toSet()
0 commit comments