diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt index 2673ccd4ffd..4fa56c7098d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt @@ -382,33 +382,7 @@ class KotlinMetadataTargetConfigurator : ).forEach { configurationName -> val configuration = project.configurations.getByName(configurationName) configuration.extendsFrom(sourceSet.resolvableMetadataConfiguration) - granularMetadataTransformation.applyToConfiguration(configuration) - } - } - } - - /** Ensure that the [configuration] excludes the dependencies that are classified by this [GranularMetadataTransformation] as - * [MetadataDependencyResolution.Exclude], and uses exactly the same versions as were resolved for the requested - * dependencies during the transformation. */ - private fun GranularMetadataTransformation.applyToConfiguration(configuration: Configuration) { - // Run this action immediately before the configuration first takes part in dependency resolution: - configuration.withDependencies { - val (unrequested, requested) = metadataDependencyResolutions - .partition { it is MetadataDependencyResolution.Exclude } - - unrequested.forEach { - val (group, name) = it.projectDependency(project)?.run { - /** Note: the project dependency notation here should be exactly this, group:name, - * not from [ModuleIds.fromProjectPathDependency], as `exclude` checks it against the project's group:name */ - ModuleDependencyIdentifier(group.toString(), name) - } ?: ModuleIds.fromComponent(project, it.dependency) - configuration.exclude(mapOf("group" to group, "module" to name)) - } - - requested.filter { it.dependency.currentBuildProjectIdOrNull == null }.forEach { - val (group, name) = ModuleIds.fromComponent(project, it.dependency) - val notation = listOfNotNull(group.orEmpty(), name, it.dependency.moduleVersion?.version).joinToString(":") - configuration.resolutionStrategy.force(notation) + configuration.shouldResolveConsistentlyWith(sourceSet.resolvableMetadataConfiguration) } } }