[Gradle][Minor] Format GranularMetadataTransformation.kt

KT-49933
This commit is contained in:
Sebastian Sellmair
2023-01-18 11:15:31 +01:00
committed by Space Team
parent e498499858
commit afec974df2
@@ -93,11 +93,13 @@ internal sealed class MetadataDependencyResolution(
}
private typealias ComponentIdentifierKey = String
/**
* This unique key can be used to lookup various info for related Resolved Dependency
* that gets serialized
*/
private val ComponentIdentifier.uniqueKey get(): ComponentIdentifierKey =
private val ComponentIdentifier.uniqueKey
get(): ComponentIdentifierKey =
when (this) {
is ProjectComponentIdentifier -> "project ${build.name}$projectPath"
is ModuleComponentIdentifier -> "module $group:$module:$version"
@@ -118,7 +120,7 @@ internal class GranularMetadataTransformation(
val projectData: Map<String, ProjectData>,
val platformCompilationSourceSets: Set<String>,
) {
constructor(project: Project, kotlinSourceSet: KotlinSourceSet): this(
constructor(project: Project, kotlinSourceSet: KotlinSourceSet) : this(
sourceSetName = kotlinSourceSet.name,
resolvedMetadataConfiguration = LazyResolvedConfiguration(kotlinSourceSet.internal.resolvableMetadataConfiguration),
sourceSetVisibilityProvider = SourceSetVisibilityProvider(project),
@@ -315,14 +317,17 @@ internal class GranularMetadataTransformation(
*/
private fun ResolvedDependencyResult.toModuleDependencyIdentifier(): ModuleDependencyIdentifier {
val component = selected
return when(val componentId = component.id) {
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 {
ModuleDependencyIdentifier(component.moduleVersion?.group ?: "unspecified", component.moduleVersion?.name ?: "unspecified")
ModuleDependencyIdentifier(
component.moduleVersion?.group ?: "unspecified",
component.moduleVersion?.name ?: "unspecified"
)
}
}
@@ -332,13 +337,14 @@ internal class GranularMetadataTransformation(
}
internal val ResolvedComponentResult.currentBuildProjectIdOrNull get(): ProjectComponentIdentifier? {
internal val ResolvedComponentResult.currentBuildProjectIdOrNull
get(): ProjectComponentIdentifier? {
val identifier = id
return when {
identifier is ProjectComponentIdentifier && identifier.build.isCurrentBuild -> identifier
else -> null
}
}
}
private fun Project.collectAllProjectsData(): Map<String, GranularMetadataTransformation.ProjectData> {
return rootProject.allprojects.associateBy { it.path }.mapValues { (path, subProject) ->
@@ -368,5 +374,5 @@ private val KotlinMultiplatformExtension.platformCompilationSourceSets: Set<Stri
internal val GranularMetadataTransformation?.metadataDependencyResolutionsOrEmpty get() = this?.metadataDependencyResolutions ?: emptyList()
internal val AttributeContainer.containsMultiplatformAttributes: Boolean get() =
keySet().any { it.name == KotlinPlatformType.attribute.name }
internal val AttributeContainer.containsMultiplatformAttributes: Boolean
get() = keySet().any { it.name == KotlinPlatformType.attribute.name }