[Gradle] KotlinProjectStructureMetadata: Use name from KotlinUsageContext by: 'kotlinVariantNameFromPublishedVariantName'
^KT-60159 Verification Pending
This commit is contained in:
committed by
Space Team
parent
fd50b80aa1
commit
84eacd5cde
+18
-7
@@ -38,7 +38,7 @@ import javax.xml.parsers.DocumentBuilderFactory
|
||||
// FIXME support module classifiers for PM2.0 or drop this class in favor of KotlinModuleIdentifier
|
||||
open class ModuleDependencyIdentifier(
|
||||
open val groupId: String?,
|
||||
open val moduleId: String
|
||||
open val moduleId: String,
|
||||
) : Serializable {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
@@ -66,7 +66,7 @@ open class ModuleDependencyIdentifier(
|
||||
|
||||
class ChangingModuleDependencyIdentifier(
|
||||
val groupIdProvider: () -> String?,
|
||||
val moduleIdProvider: () -> String
|
||||
val moduleIdProvider: () -> String,
|
||||
) : ModuleDependencyIdentifier(groupIdProvider(), moduleIdProvider()) {
|
||||
override val groupId: String?
|
||||
get() = groupIdProvider()
|
||||
@@ -78,7 +78,7 @@ sealed class SourceSetMetadataLayout(
|
||||
@get:Input
|
||||
val name: String,
|
||||
@get:Internal
|
||||
val archiveExtension: String
|
||||
val archiveExtension: String,
|
||||
) : Serializable {
|
||||
object METADATA : SourceSetMetadataLayout("metadata", "jar")
|
||||
object KLIB : SourceSetMetadataLayout("klib", "klib")
|
||||
@@ -127,7 +127,7 @@ data class KotlinProjectStructureMetadata(
|
||||
val sourceSetNames: Set<String>,
|
||||
|
||||
@Input
|
||||
val formatVersion: String = FORMAT_VERSION_0_3_3
|
||||
val formatVersion: String = FORMAT_VERSION_0_3_3,
|
||||
) : Serializable {
|
||||
@Suppress("UNUSED") // Gradle input
|
||||
@get:Input
|
||||
@@ -160,6 +160,17 @@ internal val KotlinMultiplatformExtension.kotlinProjectStructureMetadata: Kotlin
|
||||
buildKotlinProjectStructureMetadata(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the variant, taking into account that external targets might pass `.*-published` whereas
|
||||
* internally maintained targets will pass the name of the original dependency configuration
|
||||
*
|
||||
* ### Example
|
||||
* external target: `apiElements-published` -> `apiElements`
|
||||
* non-external target: `apiElements` -> `apiElements`
|
||||
*
|
||||
*/
|
||||
private val KotlinUsageContext.variantName get() = kotlinVariantNameFromPublishedVariantName(name)
|
||||
|
||||
private fun buildKotlinProjectStructureMetadata(extension: KotlinMultiplatformExtension): KotlinProjectStructureMetadata {
|
||||
val project = extension.project
|
||||
require(project.state.executed) { "Cannot build 'KotlinProjectStructureMetadata' during project configuration phase" }
|
||||
@@ -168,7 +179,7 @@ private fun buildKotlinProjectStructureMetadata(extension: KotlinMultiplatformEx
|
||||
.getByName(KotlinMultiplatformPlugin.METADATA_TARGET_NAME)
|
||||
.compilations.associateBy { it.defaultSourceSet }
|
||||
|
||||
val publishedVariantsNamesWithCompilation = project.future { getPublishedPlatformCompilations(project).mapKeys { it.key.name } }
|
||||
val publishedVariantsNamesWithCompilation = project.future { getPublishedPlatformCompilations(project).mapKeys { it.key.variantName } }
|
||||
.getOrThrow()
|
||||
|
||||
return KotlinProjectStructureMetadata(
|
||||
@@ -254,7 +265,7 @@ internal fun <Serializer> KotlinProjectStructureMetadata.serialize(
|
||||
multiNodes: Serializer.(name: String, Serializer.() -> Unit) -> Unit,
|
||||
multiNodesItem: Serializer.(name: String, Serializer.() -> Unit) -> Unit,
|
||||
value: Serializer.(key: String, value: String) -> Unit,
|
||||
multiValue: Serializer.(name: String, values: List<String>) -> Unit
|
||||
multiValue: Serializer.(name: String, values: List<String>) -> Unit,
|
||||
) = with(serializer) {
|
||||
node(ROOT_NODE_NAME) {
|
||||
value(FORMAT_VERSION_NODE_NAME, formatVersion)
|
||||
@@ -350,7 +361,7 @@ internal fun <ParsingContext> parseKotlinSourceSetMetadata(
|
||||
getRoot: () -> ParsingContext,
|
||||
valueNamed: ParsingContext.(key: String) -> String?,
|
||||
multiObjects: ParsingContext.(named: String) -> Iterable<ParsingContext>,
|
||||
multiValues: ParsingContext.(named: String) -> Iterable<String>
|
||||
multiValues: ParsingContext.(named: String) -> Iterable<String>,
|
||||
): KotlinProjectStructureMetadata {
|
||||
val projectStructureNode = getRoot()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user