Skip to content

Commit

Permalink
Make publish... tasks depend on sign... tasks (#503)
Browse files Browse the repository at this point in the history
All `publish...` tasks share Javadoc artifact (until we set up proper Javadoc generation), so this PR makes all of them dependent.

Closes #502
  • Loading branch information
petertrr authored Feb 22, 2023
1 parent f284ba6 commit d76e538
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<Jar>("dokkaJar") {
val dokkaJarProvider = tasks.register<Jar>("dokkaJar") {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
Expand All @@ -95,7 +97,7 @@ private fun Project.configurePublications() {
mavenLocal()
}
publications.withType<MavenPublication>().forEach { publication ->
publication.artifact(dokkaJar)
publication.artifact(dokkaJarProvider)
publication.pom {
name.set(project.name)
description.set(project.description ?: project.name)
Expand All @@ -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")
Expand All @@ -134,6 +136,13 @@ private fun Project.configureSigning() {
logger.lifecycle("The following publications are getting signed: ${extensions.getByType<PublishingExtension>().publications.map { it.name }}")
sign(*extensions.getByType<PublishingExtension>().publications.toTypedArray())
}

tasks.withType<PublishToMavenRepository>().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<Sign>())
}
}

private fun Project.configureNexusPublishing() {
Expand Down

0 comments on commit d76e538

Please sign in to comment.