From e6df34805faebe42a510c9953202a0b20801d8ca Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 28 Jun 2023 12:37:21 +0200 Subject: [PATCH] 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 --- libraries/kotlin.test/build.gradle.kts | 9 ++++++--- libraries/kotlin.test/wasm/build.gradle.kts | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libraries/kotlin.test/build.gradle.kts b/libraries/kotlin.test/build.gradle.kts index 8044c616afe..d5c43022b44 100644 --- a/libraries/kotlin.test/build.gradle.kts +++ b/libraries/kotlin.test/build.gradle.kts @@ -365,6 +365,7 @@ publishing { val mainPublication = register("main", MavenPublication::class) { from(rootComponent) artifact(combinedSourcesJar) + artifact(emptyJavadocJar) // Remove all optional dependencies from the root pom pom.withXml { val dependenciesNode = (asNode().get("dependencies") as NodeList).filterIsInstance().single() @@ -385,6 +386,7 @@ publishing { artifactId = "kotlin-test-$framework" from(components[framework]) 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") suppressAllPomMetadataWarnings() } @@ -397,6 +399,7 @@ publishing { artifactId = "kotlin-test-js" from(jsComponent) 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") } configureSbom( @@ -407,6 +410,7 @@ publishing { artifactId = "kotlin-test-wasm" from(wasmComponent) 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") } configureSbom( @@ -417,6 +421,7 @@ publishing { artifactId = "kotlin-test-common" from(commonMetadataComponent) 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") } configureSbom( @@ -427,15 +432,13 @@ publishing { artifactId = "kotlin-test-annotations-common" from(annotationsMetadataComponent) 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") } configureSbom( "AnnotationsCommon", "kotlin-test-annotations-common", setOf(annotationsMetadata.name), annotationsCommonPublication ) - withType { - artifact(emptyJavadocJar) - } } } diff --git a/libraries/kotlin.test/wasm/build.gradle.kts b/libraries/kotlin.test/wasm/build.gradle.kts index 521624c47ec..747cb7fbbed 100644 --- a/libraries/kotlin.test/wasm/build.gradle.kts +++ b/libraries/kotlin.test/wasm/build.gradle.kts @@ -54,3 +54,7 @@ tasks.register("sourcesJar") { from(kotlin.sourceSets["commonMain"].kotlin) from(kotlin.sourceSets["wasmMain"].kotlin) } + +tasks.register("emptyJavadocJar") { + archiveClassifier.set("javadoc") +}