Skip to content

Commit d98bf67

Browse files
committed
Update publishing to MavenCentral.
1 parent 1b7d84b commit d98bf67

File tree

4 files changed

+44
-73
lines changed

4 files changed

+44
-73
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
Publish:
1414
runs-on: ubuntu-latest
1515
env:
16-
PUBLISHING_ENABLED: true
1716
RELEASE_BUILD: ${{ inputs.isRelease }}
18-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
19-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
20-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
21-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
17+
PUBLISHING_ENABLED: true
18+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
19+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
20+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
21+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
2222
steps:
2323
- name: 'Checkout'
2424
uses: actions/checkout@v4

gradle/build-logic/src/main/kotlin/conventions.dokka.gradle.kts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,3 @@ dokka {
5050

5151
dokkaGeneratorIsolation = ClassLoaderIsolation()
5252
}
53-
54-
tasks.register<Jar>("javadocJar") {
55-
group = JavaBasePlugin.DOCUMENTATION_GROUP
56-
description = "Assembles the Javadoc Jar."
57-
from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
58-
archiveClassifier.set("javadoc")
59-
}

gradle/build-logic/src/main/kotlin/conventions.publish.gradle.kts

Lines changed: 36 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,55 @@
1-
plugins {
2-
`java-library`
3-
`maven-publish`
4-
signing
5-
}
1+
import com.vanniktech.maven.publish.JavadocJar
2+
import com.vanniktech.maven.publish.KotlinJvm
63

7-
java {
8-
withSourcesJar()
4+
plugins {
5+
id("com.vanniktech.maven.publish")
96
}
107

11-
// Configure remote Maven repositories for publishing, if any.
12-
if (System.getenv("PUBLISHING_ENABLED") == "true") {
13-
val isRelease = project.buildVersion.get().isRelease
14-
val signingKey: String? = System.getenv("SIGNING_KEY")
15-
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")
16-
val ossrhUsername: String? = System.getenv("OSSRH_USERNAME")
17-
val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD")
18-
val ossrhRepoUrl: String =
19-
if (isRelease) "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
20-
else "https://s01.oss.sonatype.org/content/repositories/snapshots/"
21-
22-
check(ossrhUsername != null && ossrhPassword != null) {
23-
"Publishing is enabled but credentials for remote repository were not given."
24-
}
8+
mavenPublishing {
259

26-
publishing.repositories.maven {
27-
url = uri(ossrhRepoUrl)
28-
credentials { username = ossrhUsername; password = ossrhPassword }
29-
}
30-
31-
if (isRelease) {
32-
check(signingKey != null && signingPassword != null) {
33-
"A release build with publishing enabled requires signing key credentials."
34-
}
35-
signing {
36-
useInMemoryPgpKeys(signingKey, signingPassword)
37-
sign(publishing.publications)
38-
}
10+
if(System.getenv("PUBLISHING_ENABLED") == "true") {
11+
publishToMavenCentral(automaticRelease = false)
12+
signAllPublications()
3913
}
40-
} else {
41-
publishing.repositories.mavenLocal()
42-
}
4314

44-
// Declare the maven publication for the current build version.
45-
publishing.publications.create<MavenPublication>(project.name) {
46-
from(components["java"])
47-
artifact(tasks.named("javadocJar"))
15+
configure(
16+
KotlinJvm(
17+
sourcesJar = true,
18+
javadocJar = JavadocJar.Dokka("dokkaGeneratePublicationHtml"),
19+
)
20+
)
4821

49-
group = "io.github.jadarma.aockt"
50-
artifactId = project.name
51-
version = project.buildVersion.get().toString()
22+
coordinates(
23+
groupId = "io.github.jadarma.aockt",
24+
artifactId = project.name,
25+
version = buildVersion.get().toString(),
26+
)
5227

5328
pom {
54-
name.set("Advent of Code Kotlin")
55-
description.set("Helper test libraries that make implementing Advent Of Code solutions a breeze.")
56-
url.set("https://jadarma.github.io/advent-of-code-kotlin")
29+
name = "Advent of Code Kotlin"
30+
description = "A simple library that makes running and testing your Kotlin solutions to Advent of Code puzzles a breeze."
31+
url = "https://jadarma.github.io/advent-of-code-kotlin"
32+
inceptionYear = "2020"
5733

5834
scm {
59-
connection.set("scm:git:git://github.com/Jadarma/advent-of-code-kotlin.git")
60-
developerConnection.set("scm:git:ssh://github.com/Jadarma/advent-of-code-kotlin.git")
61-
url.set("https://github.com/Jadarma/advent-of-code-kotlin")
35+
url = "https://github.com/Jadarma/advent-of-code-kotlin"
36+
connection = "scm:git:git://github.com/Jadarma/advent-of-code-kotlin.git"
37+
developerConnection = "scm:git:ssh://github.com/Jadarma/advent-of-code-kotlin.git"
6238
}
6339

64-
licenses {
65-
license {
66-
name.set("MIT License")
67-
url.set("https://opensource.org/license/mit")
68-
inceptionYear.set("2020")
40+
developers {
41+
developer {
42+
id = "Jadarma"
43+
name = "Dan Cîmpianu"
44+
url = "https://github.com/Jadarma"
45+
6946
}
7047
}
7148

72-
developers {
73-
developer {
74-
id.set("Jadarma")
75-
name.set("Dan Cîmpianu")
76-
email.set("[email protected]")
49+
licenses {
50+
license {
51+
name = "MIT License"
52+
url = "https://opensource.org/license/mit"
7753
}
7854
}
7955
}

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ kotest = "6.0.3" # https://mvnrepository.com/artifact/io.kotest/kotest-fr
55
detekt = "1.23.8" # https://mvnrepository.com/artifact/io.gitlab.arturbosch.detekt/detekt-gradle-plugin
66
dokka = "2.1.0-Beta" # https://mvnrepository.com/artifact/org.jetbrains.dokka/dokka-gradle-plugin
77
bcv = "0.18.1" # https://mvnrepository.com/artifact/org.jetbrains.kotlinx.binary-compatibility-validator/org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin
8+
publishing = "0.34.0" # https://mvnrepository.com/artifact/com.vanniktech/gradle-maven-publish-plugin
89

910
[libraries]
1011
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
@@ -19,7 +20,8 @@ kotlin-plugin-jvm = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", vers
1920
kotlin-plugin-bcv = { module = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin", version.ref = "bcv" }
2021
detekt-plugin = { module = "io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin", version.ref = "detekt" }
2122
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
23+
publishing-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "publishing" }
2224

2325
[bundles]
2426
kotest = [ "kotest-runner", "kotest-assertions", "kotest-property" ]
25-
gradlePlugins = [ "kotlin-plugin-jvm", "kotlin-plugin-bcv", "detekt-plugin", "dokka-plugin" ]
27+
gradlePlugins = [ "kotlin-plugin-jvm", "kotlin-plugin-bcv", "detekt-plugin", "dokka-plugin", "publishing-plugin" ]

0 commit comments

Comments
 (0)