From d76e538d207ecea23963204b614c747bb97b8617 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Wed, 22 Feb 2023 16:35:26 +0300 Subject: [PATCH] Make `publish...` tasks depend on `sign...` tasks (#503) All `publish...` tasks share Javadoc artifact (until we set up proper Javadoc generation), so this PR makes all of them dependent. Closes #502 --- .../buildutils/PublishingConfiguration.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/PublishingConfiguration.kt b/buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/PublishingConfiguration.kt index c49836286..808619eef 100644 --- a/buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/PublishingConfiguration.kt +++ b/buildSrc/src/main/kotlin/com/saveourtool/save/buildutils/PublishingConfiguration.kt @@ -11,14 +11,16 @@ import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.maven.plugins.MavenPublishPlugin import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository import org.gradle.api.tasks.bundling.Jar import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.withType import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform +import org.gradle.plugins.signing.Sign import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin @@ -83,9 +85,9 @@ fun Project.configurePublishing() { } } -@Suppress("TOO_LONG_FUNCTION") +@Suppress("TOO_LONG_FUNCTION", "GENERIC_VARIABLE_WRONG_DECLARATION") private fun Project.configurePublications() { - val dokkaJar: Jar = tasks.create("dokkaJar") { + val dokkaJarProvider = tasks.register("dokkaJar") { group = "documentation" archiveClassifier.set("javadoc") from(tasks.findByName("dokkaHtml")) @@ -95,7 +97,7 @@ private fun Project.configurePublications() { mavenLocal() } publications.withType().forEach { publication -> - publication.artifact(dokkaJar) + publication.artifact(dokkaJarProvider) publication.pom { name.set(project.name) description.set(project.description ?: project.name) @@ -111,7 +113,7 @@ private fun Project.configurePublications() { developer { id.set("petertrr") name.set("Petr Trifanov") - email.set("peter.trifanov@mail.ru") + email.set("peter.trifanov@gmail.com") } developer { id.set("akuleshov7") @@ -134,6 +136,13 @@ private fun Project.configureSigning() { logger.lifecycle("The following publications are getting signed: ${extensions.getByType().publications.map { it.name }}") sign(*extensions.getByType().publications.toTypedArray()) } + + tasks.withType().configureEach { + // Workaround for the problem described at https://github.com/saveourtool/save-cli/pull/501#issuecomment-1439705340. + // We have a single Javadoc artifact shared by all platforms, hence all publications depend on signing of this artifact. + // This causes weird implicit dependencies, like `publishJsPublication...` depends on `signJvmPublication`. + dependsOn(tasks.withType()) + } } private fun Project.configureNexusPublishing() {