oshai
05/14/2021, 7:58 AMoshai
05/14/2021, 8:13 AMVampire
05/14/2021, 8:53 AMmaven-publish
plugin, with the https://github.com/gradle-nexus/publish-plugin plugin for some sugar, more reliable uploading and automatic closing and / or releasing.Javier
05/14/2021, 9:27 AM// buildSrc/src/main/kotlin/publish-kotlin-jvm.gradle.kts
// Apply this plugin to the Kotlin JVM module should be published
plugins {
`maven-publish`
signing
id("org.jetbrains.dokka")
}
val docsJar by project.tasks.creating(Jar::class) {
group = "build"
description = "Assembles Javadoc jar file from for publishing"
archiveClassifier.set("javadoc")
dependsOn(tasks.named<DokkaTask>("dokkaHtml"))
}
val sourcesJar by project.tasks.creating(Jar::class) {
group = "build"
description = "Assembles Sources jar file for publishing"
archiveClassifier.set("sources")
from((project.properties["sourceSets"] as SourceSetContainer)["main"].allSource)
}
publishing {
publications {
withType<MavenPublication> {
pom {
name.set(property("pomName").toString())
description.set(property("pomDescription").toString())
url.set(property("pomUrl").toString())
licenses {
license {
name.set(property("pomLicenseName").toString())
url.set(property("pomLicenseUrl").toString())
}
}
developers {
developer {
id.set(property("pomDeveloperId").toString())
name.set(property("pomDeveloperName").toString())
email.set(property("pomDeveloperEmail").toString())
}
}
scm {
url.set(property("pomSmcUrl").toString())
connection.set(property("pomSmcConnection").toString())
developerConnection.set(property("pomSmcDeveloperConnection").toString())
}
}
artifact(docsJar)
artifact(sourcesJar)
}
create<MavenPublication>("maven") { from(components["java"]) }
}
}
signing {
if (!project.version.toString().endsWith("-SNAPSHOT")) {
useGpgCmd()
sign(publishing.publications)
}
}
Javier
05/14/2021, 9:28 AM// buildSrc/src/main/kotlin/nexus.gradle.kts
// Apply this plugin to the root project in the root build.gradle.kts
plugins {
id("io.github.gradle-nexus.publish-plugin")
}
nexusPublishing {
repositories {
sonatype {
username.set("${properties["oss.user"] ?: System.getenv("OSS_USER")}")
password.set("${properties["oss.token"] ?: System.getenv("OSS_TOKEN")}")
stagingProfileId.set(
"${properties["oss.stagingProfileId"] ?: System.getenv("OSS_STAGING_PROFILE_ID")}",
)
}
}
}
Javier
05/14/2021, 9:29 AMJavier
05/14/2021, 9:30 AM// gradle.properties
pomName=Gradle Plugins
pomDescription=Gradle Plugins utilities
pomUrl=<https://github.com/JavierSegoviaCordoba/gradle-plugins>
pomLicenseName=The Apache License, Version 2.0
pomLicenseUrl="<https://www.apache.org/licenses/LICENSE-2.0.txt>"
pomDeveloperId=JavierSegoviaCordoba
pomDeveloperName=Javier Segovia Cordoba
pomDeveloperEmail=javier@segoviacordoba.com
pomSmcUrl=<https://github.com/JavierSegoviaCordoba/gradle-plugins>
pomSmcConnection=scm:git:git@github.com:JavierSegoviaCordoba/gradle-plugins.git
pomSmcDeveloperConnection=scm:git:git@github.com:JavierSegoviaCordoba/gradle-plugins.git
oshai
05/19/2021, 2:03 PM