diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/SourceSetVisibilityProvider.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/SourceSetVisibilityProvider.kt index ef611c7ec0d..d580c9f5247 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/SourceSetVisibilityProvider.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/SourceSetVisibilityProvider.kt @@ -6,6 +6,9 @@ package org.jetbrains.kotlin.gradle.plugin.mpp import org.gradle.api.Project +import org.gradle.api.artifacts.component.ComponentIdentifier +import org.gradle.api.artifacts.component.ModuleComponentIdentifier +import org.gradle.api.artifacts.component.ProjectComponentIdentifier import org.gradle.api.artifacts.result.ResolvedDependencyResult import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation @@ -93,7 +96,7 @@ internal class SourceSetVisibilityProvider( val resolvedPlatformDependencies = platformCompilationData .resolvedDependenciesConfiguration .allResolvedDependencies - .filter { it.selected.id == resolvedRootMppDependencyId } + .filter { it.selected.id isEqualsIgnoringVersion resolvedRootMppDependencyId } /* Returning null if we can't find the given dependency in a certain platform compilations dependencies. This is not expected, since this means the dependency does not support the given targets which will @@ -198,3 +201,13 @@ internal class SourceSetVisibilityProvider( internal fun kotlinVariantNameFromPublishedVariantName(resolvedToVariantName: String): String = originalVariantNameFromPublished(resolvedToVariantName) ?: resolvedToVariantName + +/** + * Returns true when two components identifiers are from the same maven module (group + name) + * Gradle projects can't be resolved into multiple versions since there is only one version of a project in gradle build + */ +private infix fun ComponentIdentifier.isEqualsIgnoringVersion(that: ComponentIdentifier): Boolean { + if (this is ProjectComponentIdentifier && that is ProjectComponentIdentifier) return this == that + if (this is ModuleComponentIdentifier && that is ModuleComponentIdentifier) return this.moduleIdentifier == that.moduleIdentifier + return false +}