[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 private typealias ComponentIdentifierKey = String
/** /**
* This unique key can be used to lookup various info for related Resolved Dependency * This unique key can be used to lookup various info for related Resolved Dependency
* that gets serialized * that gets serialized
*/ */
private val ComponentIdentifier.uniqueKey get(): ComponentIdentifierKey = private val ComponentIdentifier.uniqueKey
get(): ComponentIdentifierKey =
when (this) { when (this) {
is ProjectComponentIdentifier -> "project ${build.name}$projectPath" is ProjectComponentIdentifier -> "project ${build.name}$projectPath"
is ModuleComponentIdentifier -> "module $group:$module:$version" is ModuleComponentIdentifier -> "module $group:$module:$version"
@@ -118,7 +120,7 @@ internal class GranularMetadataTransformation(
val projectData: Map<String, ProjectData>, val projectData: Map<String, ProjectData>,
val platformCompilationSourceSets: Set<String>, val platformCompilationSourceSets: Set<String>,
) { ) {
constructor(project: Project, kotlinSourceSet: KotlinSourceSet): this( constructor(project: Project, kotlinSourceSet: KotlinSourceSet) : this(
sourceSetName = kotlinSourceSet.name, sourceSetName = kotlinSourceSet.name,
resolvedMetadataConfiguration = LazyResolvedConfiguration(kotlinSourceSet.internal.resolvableMetadataConfiguration), resolvedMetadataConfiguration = LazyResolvedConfiguration(kotlinSourceSet.internal.resolvableMetadataConfiguration),
sourceSetVisibilityProvider = SourceSetVisibilityProvider(project), sourceSetVisibilityProvider = SourceSetVisibilityProvider(project),
@@ -315,14 +317,17 @@ internal class GranularMetadataTransformation(
*/ */
private fun ResolvedDependencyResult.toModuleDependencyIdentifier(): ModuleDependencyIdentifier { private fun ResolvedDependencyResult.toModuleDependencyIdentifier(): ModuleDependencyIdentifier {
val component = selected val component = selected
return when(val componentId = component.id) { 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 {
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 val identifier = id
return when { return when {
identifier is ProjectComponentIdentifier && identifier.build.isCurrentBuild -> identifier identifier is ProjectComponentIdentifier && identifier.build.isCurrentBuild -> identifier
else -> null else -> null
} }
} }
private fun Project.collectAllProjectsData(): Map<String, GranularMetadataTransformation.ProjectData> { private fun Project.collectAllProjectsData(): Map<String, GranularMetadataTransformation.ProjectData> {
return rootProject.allprojects.associateBy { it.path }.mapValues { (path, subProject) -> 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 GranularMetadataTransformation?.metadataDependencyResolutionsOrEmpty get() = this?.metadataDependencyResolutions ?: emptyList()
internal val AttributeContainer.containsMultiplatformAttributes: Boolean get() = internal val AttributeContainer.containsMultiplatformAttributes: Boolean
keySet().any { it.name == KotlinPlatformType.attribute.name } get() = keySet().any { it.name == KotlinPlatformType.attribute.name }