From c392f87019d1a756b1aee42269af6d992721637b Mon Sep 17 00:00:00 2001 From: Anton Lakotka Date: Tue, 17 Jan 2023 09:23:30 +0100 Subject: [PATCH] [Gradle] Update `ResolvedDependencyResult.toModuleDependencyIdentifier` It should work as its counterpart: ``` ModuleIds.fromComponent( thisProject: Project, component: ResolvedComponentResult ) ``` ^KT-49933 --- .../plugin/mpp/GranularMetadataTransformation.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/GranularMetadataTransformation.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/GranularMetadataTransformation.kt index cf513c30ac7..ec9b2e6c05b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/GranularMetadataTransformation.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/GranularMetadataTransformation.kt @@ -299,20 +299,19 @@ internal class GranularMetadataTransformation( ) } + /** + * Behaves as [ModuleIds.fromComponent] + */ private fun ResolvedDependencyResult.toModuleDependencyIdentifier(): ModuleDependencyIdentifier { - return when(val componentId = selected.id) { + val component = selected + return when(val componentId = component.id) { is ModuleComponentIdentifier -> ModuleDependencyIdentifier(componentId.group, componentId.module) is ProjectComponentIdentifier -> { if (componentId.build.isCurrentBuild) { params.projectData[componentId.projectPath]?.moduleId?.get() ?: error("Cant find project Module ID by ${componentId.projectPath}") } else { - when (val requestedModule = requested) { - is ProjectComponentSelector -> params.projectData[requestedModule.projectPath]?.moduleId?.get() - ?: error("Cant find project Module ID by ${requestedModule.projectPath}") - is ModuleComponentSelector -> ModuleDependencyIdentifier(requestedModule.group, requestedModule.module) - else -> error("Unknown ComponentSelector: '$requestedModule'") - } + ModuleDependencyIdentifier(component.moduleVersion?.group ?: "unspecified", component.moduleVersion?.name ?: "unspecified") } }