Migrate to new central publish

This commit is contained in:
Alexander Nozik 2024-12-09 09:22:00 +03:00
parent 0dc3458176
commit 2e1f3876af
2 changed files with 34 additions and 66 deletions

View File

@ -2,8 +2,9 @@ plugins {
`java-gradle-plugin` `java-gradle-plugin`
`kotlin-dsl` `kotlin-dsl`
`maven-publish` `maven-publish`
signing // signing
`version-catalog` `version-catalog`
alias(libs.plugins.maven.publish)
alias(libs.plugins.jetbrains.changelog) alias(libs.plugins.jetbrains.changelog)
alias(libs.plugins.jetbrains.dokka) alias(libs.plugins.jetbrains.dokka)
alias(libs.plugins.versions) alias(libs.plugins.versions)
@ -111,54 +112,36 @@ val emptySourcesJar by tasks.creating(Jar::class) {
archiveBaseName.set("empty") archiveBaseName.set("empty")
} }
publishing {
val vcs = "https://github.com/SciProgCentre/gradle-tools"
// Process each publication we have in this project mavenPublishing {
publications { val vcs = "https://git.sciprog.center/kscience/gradle-tools"
create<MavenPublication>("catalog") {
from(components["versionCatalog"])
artifactId = "version-catalog"
pom { pom {
name.set("version-catalog") name.set(project.name)
description.set(project.description)
url.set(vcs)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
} }
} }
withType<MavenPublication> { developers {
// thanks @vladimirsitnikv for the fix developer {
artifact(if (name == "catalog") emptySourcesJar else sourcesJar) id.set("SPC")
artifact(if (name == "catalog") emptyJavadocJar else javadocsJar) name.set("Scientific Programming Centre")
organization.set("SPC")
organizationUrl.set("https://sciprog.center/")
pom {
name.set(project.name)
description.set(project.description)
url.set(vcs)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("SPC")
name.set("Scientific Programming Centre")
organization.set("SPC")
organizationUrl.set("https://sciprog.center/")
}
}
scm {
url.set(vcs)
tag.set(project.version.toString())
}
} }
} }
scm {
url.set(vcs)
tag.set(project.version.toString())
}
} }
val spaceRepo = "https://maven.sciprog.center/kscience" val spaceRepo = "https://maven.sciprog.center/kscience"
@ -166,7 +149,7 @@ publishing {
val spcToken: String? = findProperty("publishing.spc.token") as? String val spcToken: String? = findProperty("publishing.spc.token") as? String
if (spcUser != null && spcToken != null) { if (spcUser != null && spcToken != null) {
repositories.maven { publishing.repositories.maven {
name = "spc" name = "spc"
url = uri(spaceRepo) url = uri(spaceRepo)
@ -177,31 +160,15 @@ publishing {
} }
} }
val sonatypeUser: String? = project.findProperty("publishing.sonatype.user") as? String val centralUser: String? = project.findProperty("mavenCentralUsername") as? String
val sonatypePassword: String? = project.findProperty("publishing.sonatype.password") as? String val centralPassword: String? = project.findProperty("mavenCentralPassword") as? String
if (sonatypeUser != null && sonatypePassword != null) { if (centralUser != null && centralPassword != null) {
val sonatypeRepo: String = if (project.version.toString().contains("dev")) { publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
"https://oss.sonatype.org/content/repositories/snapshots" signAllPublications()
} else {
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
}
repositories.maven {
name = "sonatype"
url = uri(sonatypeRepo)
credentials {
username = sonatypeUser
password = sonatypePassword
}
}
signing {
//useGpgCmd()
sign(publications)
}
} }
configure(com.vanniktech.maven.publish.VersionCatalog())
} }
kotlin { kotlin {

View File

@ -27,6 +27,7 @@ xmlutil = "0.90.3"
yamlkt = "0.13.0" yamlkt = "0.13.0"
[plugins] [plugins]
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.30.0" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" } compose-jb = { id = "org.jetbrains.compose", version.ref = "compose" }
jetbrains-changelog = "org.jetbrains.changelog:2.2.1" jetbrains-changelog = "org.jetbrains.changelog:2.2.1"