Fix publishing for gradle 8

This commit is contained in:
Alexander Nozik 2023-03-12 12:15:20 +03:00
parent d0079ba307
commit e535fdc6f5
5 changed files with 117 additions and 100 deletions

View File

@ -104,8 +104,19 @@ val javadocsJar by tasks.creating(Jar::class) {
from(tasks.dokkaHtml) from(tasks.dokkaHtml)
} }
afterEvaluate { val emptyJavadocJar by tasks.creating(Jar::class) {
publishing { group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveBaseName.set("empty")
archiveClassifier.set("javadoc")
}
val emptySourcesJar by tasks.creating(Jar::class) {
archiveClassifier.set("sources")
archiveBaseName.set("empty")
}
publishing {
val vcs = "https://github.com/mipt-npm/gradle-tools" val vcs = "https://github.com/mipt-npm/gradle-tools"
// Process each publication we have in this project // Process each publication we have in this project
@ -120,8 +131,10 @@ afterEvaluate {
} }
withType<MavenPublication> { withType<MavenPublication> {
artifact(sourcesJar) // thanks @vladimirsitnikv for the fix
artifact(javadocsJar) artifact(if (name == "catalog") emptySourcesJar else sourcesJar)
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar)
pom { pom {
name.set(project.name) name.set(project.name)
@ -191,20 +204,16 @@ afterEvaluate {
} }
} }
if (plugins.findPlugin("signing") == null) {
apply<SigningPlugin>()
}
signing { signing {
//useGpgCmd() //useGpgCmd()
sign(publications) sign(publications)
} }
} }
}
} }
kotlin{
jvmToolchain{ kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11)) languageVersion.set(JavaLanguageVersion.of(11))
} }
} }
@ -213,3 +222,8 @@ tasks.processResources.configure {
duplicatesStrategy = DuplicatesStrategy.INCLUDE duplicatesStrategy = DuplicatesStrategy.INCLUDE
from("gradle/libs.versions.toml") from("gradle/libs.versions.toml")
} }
// Workaround for https://github.com/gradle/gradle/issues/15568
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
}

View File

@ -1,11 +1,11 @@
[versions] [versions]
tools = "0.14.3-kotlin-1.8.10" tools = "0.14.4-kotlin-1.8.20-RC"
kotlin = "1.8.10" kotlin = "1.8.20-RC"
atomicfu = "0.19.0" atomicfu = "0.19.0"
binary-compatibility-validator = "0.12.1" binary-compatibility-validator = "0.12.1"
changelog = "2.0.0" changelog = "2.0.0"
dokka = "1.7.20" dokka = "1.7.20"
kotlin-jupyter = "0.11.0-225" kotlin-jupyter = "0.11.0-317"
kotlinx-benchmark = "0.4.7" kotlinx-benchmark = "0.4.7"
kotlinx-cli = "0.3.5" kotlinx-cli = "0.3.5"
kotlinx-coroutines = "1.6.4" kotlinx-coroutines = "1.6.4"
@ -17,7 +17,7 @@ kotlinx-serialization = "1.4.1"
ktor = "2.2.3" ktor = "2.2.3"
xmlutil = "0.84.3" xmlutil = "0.84.3"
yamlkt = "0.12.0" yamlkt = "0.12.0"
jsBom = "1.0.0-pre.491" jsBom = "1.0.0-pre.509"
junit = "5.9.2" junit = "5.9.2"
compose = "1.3.0" compose = "1.3.0"
logback = "1.4.5" logback = "1.4.5"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -5,7 +5,9 @@ import kotlinx.validation.BinaryCompatibilityValidatorPlugin
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPom
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.Sign
import org.jetbrains.changelog.ChangelogPlugin import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.changelog.ChangelogPluginExtension import org.jetbrains.changelog.ChangelogPluginExtension
import org.jetbrains.dokka.gradle.AbstractDokkaTask import org.jetbrains.dokka.gradle.AbstractDokkaTask
@ -108,6 +110,11 @@ public open class KScienceProjectPlugin : Plugin<Project> {
maven("https://repo.kotlin.link") maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev") maven("https://maven.pkg.jetbrains.space/spc/p/sci/dev")
} }
// Workaround for https://github.com/gradle/gradle/issues/15568
tasks.withType<AbstractPublishToMaven>().configureEach {
mustRunAfter(tasks.withType<Sign>())
}
} }
afterEvaluate { afterEvaluate {

View File

@ -34,7 +34,6 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
} }
} }
afterEvaluate {
publications.create<MavenPublication>("js") { publications.create<MavenPublication>("js") {
kotlin.targets.flatMap { it.components }.forEach { kotlin.targets.flatMap { it.components }.forEach {
from(it) from(it)
@ -42,7 +41,6 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
artifact(sourcesJar) artifact(sourcesJar)
} }
}
} }
@ -56,7 +54,6 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
} }
} }
afterEvaluate {
publications.create<MavenPublication>("jvm") { publications.create<MavenPublication>("jvm") {
kotlin.target.components.forEach { kotlin.target.components.forEach {
from(it) from(it)
@ -65,7 +62,6 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
artifact(sourcesJar) artifact(sourcesJar)
} }
} }
}
val dokkaJar by tasks.creating(Jar::class) { val dokkaJar by tasks.creating(Jar::class) {
group = "documentation" group = "documentation"