[Gradle] Update ResolvedDependencyResult.toModuleDependencyIdentifier

It should work as its counterpart:

```
ModuleIds.fromComponent(
    thisProject: Project,
    component: ResolvedComponentResult
)
```

^KT-49933
This commit is contained in:
Anton Lakotka
2023-01-17 09:23:30 +01:00
committed by Space Team
parent 5094ac945c
commit c392f87019
@@ -299,20 +299,19 @@ internal class GranularMetadataTransformation(
) )
} }
/**
* Behaves as [ModuleIds.fromComponent]
*/
private fun ResolvedDependencyResult.toModuleDependencyIdentifier(): ModuleDependencyIdentifier { 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 ModuleComponentIdentifier -> ModuleDependencyIdentifier(componentId.group, componentId.module)
is ProjectComponentIdentifier -> { is ProjectComponentIdentifier -> {
if (componentId.build.isCurrentBuild) { if (componentId.build.isCurrentBuild) {
params.projectData[componentId.projectPath]?.moduleId?.get() params.projectData[componentId.projectPath]?.moduleId?.get()
?: error("Cant find project Module ID by ${componentId.projectPath}") ?: error("Cant find project Module ID by ${componentId.projectPath}")
} else { } else {
when (val requestedModule = requested) { ModuleDependencyIdentifier(component.moduleVersion?.group ?: "unspecified", component.moduleVersion?.name ?: "unspecified")
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'")
}
} }
} }