Skip to content

Commit 8ce2b3e

Browse files
committed
Try and publish to maven central
1 parent 693db61 commit 8ce2b3e

File tree

9 files changed

+135
-61
lines changed

9 files changed

+135
-61
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,18 @@ jobs:
163163
- name: Setup Gradle
164164
uses: gradle/actions/setup-gradle@v4
165165

166+
- name: Install GPG secret key
167+
run: |
168+
cat <(echo -e "${{ secrets.SONATYPE_GPG_KEY }}") | gpg --batch --import
169+
gpg --list-secret-keys --keyid-format LONG
170+
166171
- name: Publish libraries
167172
run: ./gradlew publish
168173
env:
169174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170175
CAPLIN_USERNAME: ${{ secrets.CAPLIN_USERNAME }}
171176
CAPLIN_PASSWORD: ${{ secrets.CAPLIN_PASSWORD }}
177+
ORG_GRADLE_PROJECT_signing.keyId: "BD2A1230"
178+
ORG_GRADLE_PROJECT_signing.password: ${{ secrets.SONATYPE_GPG_PASSWORD }}
179+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
180+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}

buildSrc/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
`kotlin-dsl`
3-
id("com.ncorti.ktfmt.gradle") version libs.versions.ktfmtPlugin
3+
id("com.ncorti.ktfmt.gradle") version libs.versions.ktfmt.plugin
44
}
55

66
dependencies {
@@ -12,4 +12,5 @@ dependencies {
1212
implementation(libs.kotlin.plugin)
1313
implementation(libs.kotlin.allopen.plugin)
1414
implementation(libs.kotlinpoet.plugin)
15+
implementation(libs.vanniktech.maven.publish.plugin)
1516
}

buildSrc/src/main/kotlin/common-dokka.gradle.kts

Lines changed: 0 additions & 5 deletions
This file was deleted.

buildSrc/src/main/kotlin/common-library.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
1+
import com.vanniktech.maven.publish.JavadocJar
2+
import com.vanniktech.maven.publish.KotlinJvm
3+
import gradle.kotlin.dsl.accessors._94cffe4e74c4f6a3b1c88c3e0c336ef5.mavenPublishing
24
import org.gradle.api.JavaVersion.VERSION_17
35
import org.gradle.api.file.DuplicatesStrategy.WARN
46

57
plugins {
68
id("common-maven")
7-
id("common-dokka")
89
kotlin("jvm")
910
`java-library`
1011
idea
1112
id("org.jetbrains.kotlinx.kover")
1213
id("org.jetbrains.kotlinx.binary-compatibility-validator")
1314
id("com.ncorti.ktfmt.gradle")
1415
id("io.gitlab.arturbosch.detekt")
16+
id("org.jetbrains.dokka")
1517
}
1618

1719
java {
@@ -26,9 +28,7 @@ tasks.jar { duplicatesStrategy = WARN }
2628

2729
tasks.test {
2830
useJUnitPlatform()
29-
reports {
30-
junitXml.required.set(true)
31-
}
31+
reports { junitXml.required.set(true) }
3232
}
3333

3434
dokka {
@@ -46,13 +46,13 @@ dokka {
4646
}
4747
}
4848

49-
publishing {
50-
publications {
51-
register<MavenPublication>("maven") {
52-
from(components["java"])
53-
versionMapping { allVariants { fromResolutionResult() } }
54-
}
55-
}
49+
mavenPublishing {
50+
configure(
51+
KotlinJvm(
52+
javadocJar = JavadocJar.Dokka("dokkaGeneratePublicationHtml"),
53+
sourcesJar = true,
54+
)
55+
)
5656
}
5757

5858
sourceSets {

buildSrc/src/main/kotlin/common-maven.gradle.kts

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,57 @@
1-
plugins { `maven-publish` }
1+
import com.vanniktech.maven.publish.SonatypeHost.Companion.CENTRAL_PORTAL
2+
3+
plugins { id("com.vanniktech.maven.publish") }
24

35
group = "com.caplin.integration.datasourcex"
46

5-
val configuredVersion =
6-
System.getenv("GITHUB_REF_NAME") ?: "dev"
7+
val configuredVersion = System.getenv("GITHUB_REF_NAME") ?: "dev"
78

89
version = configuredVersion
910

11+
mavenPublishing {
12+
publishToMavenCentral(CENTRAL_PORTAL)
13+
14+
signAllPublications()
15+
16+
pom {
17+
url = "https://github.com/caplin/DataSource-Extensions"
18+
inceptionYear = "2025"
19+
20+
issueManagement {
21+
url = "https://github.com/caplin/DataSource-Extensions/issues"
22+
system = "GitHub"
23+
}
24+
25+
licenses {
26+
license {
27+
name.set("The Apache License, Version 2.0")
28+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
29+
distribution.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
30+
}
31+
}
32+
scm {
33+
url.set("https://github.com/caplin/DataSource-Extensions")
34+
connection.set("scm:git:git://github.com/caplin/DataSource-Extensions.git")
35+
developerConnection.set("scm:git:ssh://[email protected]/caplin/DataSource-Extensions.git")
36+
}
37+
}
38+
}
39+
1040
publishing {
1141
repositories {
12-
maven {
13-
name = "GitHubPackages"
14-
url = uri("https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY") ?: "caplin/DataSource-Extensions"}")
15-
credentials {
16-
username = System.getenv("GITHUB_ACTOR")
17-
password = System.getenv("GITHUB_TOKEN")
42+
val githubActor = System.getenv("GITHUB_ACTOR")
43+
val githubToken = System.getenv("GITHUB_TOKEN")
44+
if (githubActor != null && githubToken != null) {
45+
maven {
46+
name = "GitHubPackages"
47+
url =
48+
uri(
49+
"https://maven.pkg.github.com/caplin/DataSource-Extensions",
50+
)
51+
credentials {
52+
username = githubActor
53+
password = githubToken
54+
}
1855
}
1956
}
2057
}

docs/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
`common-dokka`
2+
id("org.jetbrains.dokka")
33
}
44

55
dependencies {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ kotlin.code.style=official
55
org.gradle.parallel=true
66

77
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
8-
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
8+
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true

gradle/libs.versions.toml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
springBoot = "3.5.0+"
2+
springBoot = "3.5.0"
33
kotlin = "1.9.25" # Keep in sync with Spring - https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions.html
44
kotlinCollectionsImmutable = "0.3.8"
55
jsonPatch = "1.13"
@@ -15,12 +15,14 @@ mockk = "1.13.14"
1515
# Spring BOM should manage other dependencies versions.
1616

1717
# Plugins
18-
ktfmtPlugin = "0.21.0"
19-
dokkaPlugin = "2.0.0"
20-
binaryCompatibilityValidatorPlugin = "0.17.0"
21-
koverPlugin = "0.9.1"
22-
kotlinpoetPlugin = "2.1.0"
23-
detektPlugin = "1.23.8"
18+
ktfmt-plugin = "0.21.0"
19+
dokka-plugin = "2.0.0"
20+
binary-compatibility-validator-plugin = "0.17.0"
21+
kover-plugin = "0.9.1"
22+
kotlinpoet-plugin = "2.1.0"
23+
detekt-plugin = "1.23.8"
24+
vanniktech-maven-publish-plugin = "0.31.0"
25+
2426

2527
[libraries]
2628
kotlin-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinCollectionsImmutable" }
@@ -36,14 +38,15 @@ turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
3638
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
3739

3840
# Plugins
39-
detekt-plugin = { module = "io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin", version.ref = "detektPlugin" }
40-
ktfmt-plugin = { module = "com.ncorti.ktfmt.gradle:plugin", version.ref = "ktfmtPlugin" }
41-
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokkaPlugin" }
42-
binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binaryCompatibilityValidatorPlugin" }
43-
kover-plugin = { module = "org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin", version.ref = "koverPlugin" }
44-
kotlinpoet-plugin = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoetPlugin" }
41+
detekt-plugin = { module = "io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin", version.ref = "detekt-plugin" }
42+
ktfmt-plugin = { module = "com.ncorti.ktfmt.gradle:plugin", version.ref = "ktfmt-plugin" }
43+
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka-plugin" }
44+
binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "binary-compatibility-validator-plugin" }
45+
kover-plugin = { module = "org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin", version.ref = "kover-plugin" }
46+
kotlinpoet-plugin = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet-plugin" }
4547
kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
4648
kotlin-allopen-plugin = { module = "org.jetbrains.kotlin.plugin.allopen:org.jetbrains.kotlin.plugin.allopen.gradle.plugin", version.ref = "kotlin" }
49+
vanniktech-maven-publish-plugin = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin", version.ref = "vanniktech-maven-publish-plugin"}
4750

4851
# BOMs
4952
spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "springBoot" }

version-catalog/build.gradle.kts

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
1+
import com.vanniktech.maven.publish.VersionCatalog
2+
13
plugins {
2-
`common-maven`
3-
`version-catalog`
4+
`common-maven`
5+
`version-catalog`
46
}
57

68
catalog {
7-
versionCatalog {
8-
from(files("$rootDir/gradle/libs.versions.toml"))
9-
version(rootProject.name, rootProject.version.toString())
10-
library("datasourcex-util", project.group.toString(), "datasourcex-util").versionRef(rootProject.name)
11-
library("datasourcex-reactive-api", project.group.toString(), "datasourcex-reactive-api").versionRef(rootProject.name)
12-
library("datasourcex-reactive-core", project.group.toString(), "datasourcex-reactive-core").versionRef(rootProject.name)
13-
library("datasourcex-java-flow", project.group.toString(), "datasourcex-java-flow").versionRef(rootProject.name)
14-
library("datasourcex-kotlin", project.group.toString(), "datasourcex-kotlin").versionRef(rootProject.name)
15-
library("datasourcex-reactivestreams", project.group.toString(), "datasourcex-reactivestreams").versionRef(rootProject.name)
16-
library("datasourcex-spring", project.group.toString(), "datasourcex-spring").versionRef(rootProject.name)
17-
}
9+
val springBootStarterDataSource = project(":spring-boot-starter-datasource")
10+
val util = project(":datasourcex-util")
11+
val reactiveApi = project(":reactive:datasourcex-reactive-api")
12+
val reactiveCore = project(":reactive:datasourcex-reactive-core")
13+
val javaFlow = project(":reactive:datasourcex-java-flow")
14+
val kotlin = project(":reactive:datasourcex-kotlin")
15+
val reactiveStreams = project(":reactive:datasourcex-reactivestreams")
16+
versionCatalog {
17+
version("spring-boot", libs.versions.springBoot.get())
18+
version(rootProject.name, util.version.toString())
19+
library(
20+
util.name,
21+
project.group.toString(),
22+
util.name,
23+
).versionRef(rootProject.name)
24+
library(
25+
reactiveApi.name,
26+
project.group.toString(),
27+
reactiveApi.name,
28+
).versionRef(rootProject.name)
29+
library(
30+
reactiveCore.name,
31+
project.group.toString(),
32+
reactiveCore.name,
33+
).versionRef(rootProject.name)
34+
library(javaFlow.name, project.group.toString(), javaFlow.name).versionRef(
35+
rootProject.name,
36+
)
37+
library(kotlin.name, project.group.toString(), kotlin.name).versionRef(
38+
rootProject.name,
39+
)
40+
library(
41+
reactiveStreams.name,
42+
project.group.toString(),
43+
reactiveStreams.name,
44+
).versionRef(rootProject.name)
45+
library(
46+
springBootStarterDataSource.name,
47+
project.group.toString(),
48+
springBootStarterDataSource.name,
49+
).versionRef(rootProject.name)
50+
}
1851
}
1952

20-
publishing {
21-
publications {
22-
register<MavenPublication>("maven") {
23-
from(components["versionCatalog"])
24-
}
25-
}
53+
mavenPublishing {
54+
configure(VersionCatalog())
2655
}

0 commit comments

Comments
 (0)