Fix POM not rewritten correctly with custom artifact IDs (KT-29485)
When the plugin rewrites a POM, it establishes the mapping of the original Maven coordinates to the modified ones. As one of the steps, this requires finding the original Maven coordinates to rewrite – these should be exactly the coordinates that Gradle writes to the POM. In MPP, these are the coordinates of the 'root' (Gradle module metadata) publication. If those are modified in the publication, the plugin relies on delegating to the publication in the root module's SotwareComponent (the only reasonable fallback is the project's name, and in this case it obviously doesn't match the Maven artifact ID that was modified). In 1.3.20, the publication delegate was never assigned. To fix the issue, it is enough to correctly assign the publication delegate for the root module's SoftwareComponent. Issue #KT-29485 Fixed
This commit is contained in:
+20
-3
@@ -1201,7 +1201,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
)
|
||||
}
|
||||
|
||||
gradleBuildScript().appendText("\n" + """
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
publishing {
|
||||
publications {
|
||||
jvm6 {
|
||||
@@ -1211,7 +1212,23 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
if (withMetadata) {
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
publishing {
|
||||
publications {
|
||||
kotlinMultiplatform {
|
||||
// KT-29485
|
||||
artifactId = 'sample-lib-multiplatform'
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
build("clean", "publish") {
|
||||
assertSuccessful()
|
||||
@@ -1240,7 +1257,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
// Check that, despite the rewritten POM, the module metadata contains the original dependency:
|
||||
val moduleMetadata = projectDir.resolve("repo/com/exampleapp/sample-app-jvm8/1.0/sample-app-jvm8-1.0.module").readText()
|
||||
.replace("\\s+".toRegex(), "").replace("\n", "")
|
||||
assertTrue { "\"group\":\"com.example\",\"module\":\"sample-lib\"" in moduleMetadata }
|
||||
assertTrue { "\"group\":\"com.example\",\"module\":\"sample-lib-multiplatform\"" in moduleMetadata }
|
||||
assertTrue { "\"group\":\"com.external.dependency\",\"module\":\"external\"" in moduleMetadata }
|
||||
}
|
||||
assertFileExists("repo/foo/bar/42/bar-42.jar")
|
||||
|
||||
+1
@@ -171,6 +171,7 @@ class KotlinMultiplatformPlugin(
|
||||
val rootPublication = publishing.publications.create("kotlinMultiplatform", MavenPublication::class.java).apply {
|
||||
from(kotlinSoftwareComponent)
|
||||
(this as MavenPublicationInternal).publishWithOriginalFileName()
|
||||
kotlinSoftwareComponent.publicationDelegate = this@apply
|
||||
}
|
||||
|
||||
// Publish the root publication only if Gradle metadata publishing is enabled:
|
||||
|
||||
Reference in New Issue
Block a user