Fix getChosenVariant implementation for project(...) dependencies
This commit is contained in:
+7
-6
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@@ -12,7 +12,6 @@ import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ModuleDependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.artifacts.result.ResolvedComponentResult
|
||||
import org.gradle.api.artifacts.result.ResolvedDependencyResult
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
@@ -288,11 +287,13 @@ class GradleModuleVariantResolver(val project: Project) : ModuleVariantResolver
|
||||
|
||||
val dependencyModuleId = ModuleIds.fromComponent(project, component)
|
||||
// FIXME check composite builds, it's likely that resolvedVariantProvider fails on them?
|
||||
val variantName =
|
||||
resolvedVariantProvider.getResolvedVariantName(dependencyModuleId, compileClasspath)
|
||||
?.let(::kotlinVariantNameFromPublishedVariantName)
|
||||
val resolvedGradleVariantName = resolvedVariantProvider.getResolvedVariantName(dependencyModuleId, compileClasspath)
|
||||
val kotlinVariantName = when (dependencyModule) {
|
||||
is KotlinGradleModule -> dependencyModule.variants.single { resolvedGradleVariantName in it.gradleVariantNames }.name
|
||||
else -> resolvedGradleVariantName?.let(::kotlinVariantNameFromPublishedVariantName)
|
||||
}
|
||||
|
||||
val resultVariant = dependencyModule.variants.singleOrNull { it.fragmentName == variantName }
|
||||
val resultVariant = dependencyModule.variants.singleOrNull { it.fragmentName == kotlinVariantName }
|
||||
|
||||
return if (resultVariant == null)
|
||||
VariantResolution.NoVariantMatch(requestingVariant, dependencyModule)
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class GradleKotlinDependencyGraphResolver(
|
||||
(module as? ExternalImportedKotlinModule)
|
||||
?.takeIf { it.hasLegacyMetadataModule }
|
||||
?.let { (component.dependencies.singleOrNull() as? ResolvedDependencyResult)?.selected }
|
||||
?: component
|
||||
?: component
|
||||
|
||||
val resolvedComponentDependencies = componentContainingTransitiveDependencies.dependencies
|
||||
.filterIsInstance<ResolvedDependencyResult>()
|
||||
|
||||
+2
@@ -13,6 +13,7 @@ import org.gradle.api.component.SoftwareComponentFactory
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.maven.MavenPublication
|
||||
import org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.CalculatedCapability
|
||||
@@ -171,6 +172,7 @@ abstract class AbstractKotlinGradleRuntimePublishedVariantFactory<T : KotlinGrad
|
||||
project.pluginManager.withPlugin("maven-publish") {
|
||||
project.extensions.getByType(PublishingExtension::class.java).apply {
|
||||
publications.create(platformComponentName, MavenPublication::class.java).apply {
|
||||
(this as DefaultMavenPublication).isAlias = true
|
||||
from(platformComponent)
|
||||
variant.assignMavenPublication(this)
|
||||
artifactId = dashSeparatedName(project.name, variant.defaultPublishedModuleSuffix)
|
||||
|
||||
Reference in New Issue
Block a user