Fix Gradle implicit dependency error in kotlin-test when signing enabled

Remove dependency to same javadoc jar in all publications as it produces
an implicit dependency to the same signing task. Use different javadoc
tasks instead.

Error:

org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':kotlin-test:signCommonPublication' (type 'Sign').
 - Gradle detected a problem with the following location: '/kotlin/libraries/kotlin.test/build/distributions/kotlin-test-1.9.20-dev-0000-javadoc.jar.asc'.

  Reason: Task ':kotlin-test:publishAnnotationsCommonPublicationToMavenLocal' uses this output of task ':kotlin-test:signCommonPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Reproduce:

gradle :kotlin-test:publishToMavenLocal -Psigning.gnupg.keyName=***** -Psigning.gnupg.passphrase=**** -PsigningRequired=true

KTI-1282
This commit is contained in:
Nikolay Krasko
2023-06-28 12:37:21 +02:00
committed by Space Team
parent 27600eecb3
commit e6df34805f
2 changed files with 10 additions and 3 deletions
+6 -3
View File
@@ -365,6 +365,7 @@ publishing {
val mainPublication = register("main", MavenPublication::class) { val mainPublication = register("main", MavenPublication::class) {
from(rootComponent) from(rootComponent)
artifact(combinedSourcesJar) artifact(combinedSourcesJar)
artifact(emptyJavadocJar)
// Remove all optional dependencies from the root pom // Remove all optional dependencies from the root pom
pom.withXml { pom.withXml {
val dependenciesNode = (asNode().get("dependencies") as NodeList).filterIsInstance<Node>().single() val dependenciesNode = (asNode().get("dependencies") as NodeList).filterIsInstance<Node>().single()
@@ -385,6 +386,7 @@ publishing {
artifactId = "kotlin-test-$framework" artifactId = "kotlin-test-$framework"
from(components[framework]) from(components[framework])
artifact(tasks.getByPath(":kotlin-test:kotlin-test-$framework:sourcesJar") as Jar) artifact(tasks.getByPath(":kotlin-test:kotlin-test-$framework:sourcesJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-$framework:javadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test Support for $framework") configureKotlinPomAttributes(project, "Kotlin Test Support for $framework")
suppressAllPomMetadataWarnings() suppressAllPomMetadataWarnings()
} }
@@ -397,6 +399,7 @@ publishing {
artifactId = "kotlin-test-js" artifactId = "kotlin-test-js"
from(jsComponent) from(jsComponent)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-js:sourcesJar") as Jar) artifact(tasks.getByPath(":kotlin-test:kotlin-test-js:sourcesJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-js:javadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test for JS") configureKotlinPomAttributes(project, "Kotlin Test for JS")
} }
configureSbom( configureSbom(
@@ -407,6 +410,7 @@ publishing {
artifactId = "kotlin-test-wasm" artifactId = "kotlin-test-wasm"
from(wasmComponent) from(wasmComponent)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-wasm:sourcesJar") as Jar) artifact(tasks.getByPath(":kotlin-test:kotlin-test-wasm:sourcesJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-wasm:emptyJavadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test for WASM", packaging = "klib") configureKotlinPomAttributes(project, "Kotlin Test for WASM", packaging = "klib")
} }
configureSbom( configureSbom(
@@ -417,6 +421,7 @@ publishing {
artifactId = "kotlin-test-common" artifactId = "kotlin-test-common"
from(commonMetadataComponent) from(commonMetadataComponent)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-common:sourcesJar") as Jar) artifact(tasks.getByPath(":kotlin-test:kotlin-test-common:sourcesJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-common:javadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test Common") configureKotlinPomAttributes(project, "Kotlin Test Common")
} }
configureSbom( configureSbom(
@@ -427,15 +432,13 @@ publishing {
artifactId = "kotlin-test-annotations-common" artifactId = "kotlin-test-annotations-common"
from(annotationsMetadataComponent) from(annotationsMetadataComponent)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-annotations-common:sourcesJar") as Jar) artifact(tasks.getByPath(":kotlin-test:kotlin-test-annotations-common:sourcesJar") as Jar)
artifact(tasks.getByPath(":kotlin-test:kotlin-test-annotations-common:javadocJar") as Jar)
configureKotlinPomAttributes(project, "Kotlin Test Common") configureKotlinPomAttributes(project, "Kotlin Test Common")
} }
configureSbom( configureSbom(
"AnnotationsCommon", "kotlin-test-annotations-common", "AnnotationsCommon", "kotlin-test-annotations-common",
setOf(annotationsMetadata.name), annotationsCommonPublication setOf(annotationsMetadata.name), annotationsCommonPublication
) )
withType<MavenPublication> {
artifact(emptyJavadocJar)
}
} }
} }
@@ -54,3 +54,7 @@ tasks.register<Jar>("sourcesJar") {
from(kotlin.sourceSets["commonMain"].kotlin) from(kotlin.sourceSets["commonMain"].kotlin)
from(kotlin.sourceSets["wasmMain"].kotlin) from(kotlin.sourceSets["wasmMain"].kotlin)
} }
tasks.register<Jar>("emptyJavadocJar") {
archiveClassifier.set("javadoc")
}