[Gradle][Minor] Format GranularMetadataTransformation.kt
KT-49933
This commit is contained in:
committed by
Space Team
parent
e498499858
commit
afec974df2
+25
-19
@@ -93,16 +93,18 @@ 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
|
||||||
when (this) {
|
get(): ComponentIdentifierKey =
|
||||||
is ProjectComponentIdentifier -> "project ${build.name}$projectPath"
|
when (this) {
|
||||||
is ModuleComponentIdentifier -> "module $group:$module:$version"
|
is ProjectComponentIdentifier -> "project ${build.name}$projectPath"
|
||||||
else -> error("Unexpected Component Identifier: '$this' of type $javaClass")
|
is ModuleComponentIdentifier -> "module $group:$module:$version"
|
||||||
}
|
else -> error("Unexpected Component Identifier: '$this' of type $javaClass")
|
||||||
|
}
|
||||||
|
|
||||||
internal class GranularMetadataTransformation(
|
internal class GranularMetadataTransformation(
|
||||||
val params: Params,
|
val params: Params,
|
||||||
@@ -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),
|
||||||
@@ -235,8 +237,8 @@ internal class GranularMetadataTransformation(
|
|||||||
.singleOrNull()
|
.singleOrNull()
|
||||||
// Make sure that resolved metadata artifact is actually Multiplatform one
|
// Make sure that resolved metadata artifact is actually Multiplatform one
|
||||||
?.takeIf { it.variant.attributes.containsMultiplatformAttributes }
|
?.takeIf { it.variant.attributes.containsMultiplatformAttributes }
|
||||||
// expected only ony Composite Metadata Klib, but if dependency got resolved into platform variant
|
// expected only ony Composite Metadata Klib, but if dependency got resolved into platform variant
|
||||||
// when source set is a leaf then we might get multiple artifacts in such case we must return KeepOriginal
|
// when source set is a leaf then we might get multiple artifacts in such case we must return KeepOriginal
|
||||||
?: return MetadataDependencyResolution.KeepOriginalDependency(module)
|
?: return MetadataDependencyResolution.KeepOriginalDependency(module)
|
||||||
|
|
||||||
logger.debug("Transform composite metadata artifact: '${compositeMetadataArtifact.file}'")
|
logger.debug("Transform composite metadata artifact: '${compositeMetadataArtifact.file}'")
|
||||||
@@ -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
|
||||||
val identifier = id
|
get(): ProjectComponentIdentifier? {
|
||||||
return when {
|
val identifier = id
|
||||||
identifier is ProjectComponentIdentifier && identifier.build.isCurrentBuild -> identifier
|
return when {
|
||||||
else -> null
|
identifier is ProjectComponentIdentifier && identifier.build.isCurrentBuild -> identifier
|
||||||
|
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 }
|
||||||
Reference in New Issue
Block a user