Fix publication failed in projects which are using BOM.
^KT-47444 Fixed
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
|
||||||
|
@DisplayName("Artifacts publication")
|
||||||
|
@SimpleGradlePluginTests
|
||||||
|
class PublishingIT : KGPBaseTest() {
|
||||||
|
|
||||||
|
private val String.fullProjectName get() = "publishing/$this"
|
||||||
|
|
||||||
|
@DisplayName("Should allow to publish library in project which is using BOM (KT-47444)")
|
||||||
|
@GradleTest
|
||||||
|
internal fun shouldPublishCorrectlyWithOmittedVersion(gradleVersion: GradleVersion) {
|
||||||
|
project("withBom".fullProjectName, gradleVersion) {
|
||||||
|
build("publishToMavenLocal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
plugins {
|
||||||
|
id 'org.jetbrains.kotlin.jvm'
|
||||||
|
id 'maven-publish'
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "org.example"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
maven(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(platform("com.fasterxml.jackson:jackson-bom:2.12.3"))
|
||||||
|
implementation("com.fasterxml.jackson.core:jackson-core")
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package testProject.publishing.withBom.src.main.kotlin
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
fun one() = "One"
|
||||||
|
}
|
||||||
+3
-2
@@ -11,6 +11,7 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.XmlProvider
|
import org.gradle.api.XmlProvider
|
||||||
import org.gradle.api.artifacts.ModuleDependency
|
import org.gradle.api.artifacts.ModuleDependency
|
||||||
import org.gradle.api.artifacts.ProjectDependency
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
|
import org.gradle.api.artifacts.ResolvedDependency
|
||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.api.internal.component.SoftwareComponentInternal
|
import org.gradle.api.internal.component.SoftwareComponentInternal
|
||||||
import org.gradle.api.internal.component.UsageContext
|
import org.gradle.api.internal.component.UsageContext
|
||||||
@@ -133,7 +134,7 @@ private fun associateDependenciesWithActualModuleDependencies(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
val resolvedDependencies by lazy {
|
val resolvedDependencies: Map<Triple<String?, String, String?>, ResolvedDependency> by lazy {
|
||||||
// don't resolve if no project dependencies on MPP projects are found
|
// don't resolve if no project dependencies on MPP projects are found
|
||||||
targetDependenciesConfiguration.resolvedConfiguration.lenientConfiguration.allModuleDependencies.associateBy {
|
targetDependenciesConfiguration.resolvedConfiguration.lenientConfiguration.allModuleDependencies.associateBy {
|
||||||
Triple(it.moduleGroup, it.moduleName, it.moduleVersion)
|
Triple(it.moduleGroup, it.moduleName, it.moduleVersion)
|
||||||
@@ -185,7 +186,7 @@ private fun associateDependenciesWithActualModuleDependencies(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val resolvedDependency = resolvedDependencies[Triple(dependency.group!!, dependency.name, dependency.version!!)]
|
val resolvedDependency = resolvedDependencies[Triple(dependency.group, dependency.name, dependency.version)]
|
||||||
?: return@associate noMapping
|
?: return@associate noMapping
|
||||||
|
|
||||||
if (resolvedDependency.moduleArtifacts.isEmpty() && resolvedDependency.children.size == 1) {
|
if (resolvedDependency.moduleArtifacts.isEmpty() && resolvedDependency.children.size == 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user