Skip to content

Commit 6925411

Browse files
committed
Use maven publish plugin
1 parent f67c825 commit 6925411

File tree

4 files changed

+23
-60
lines changed

4 files changed

+23
-60
lines changed

build.gradle.kts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
alias(libs.plugins.kotlin.binaryCompatibility)
3-
alias(libs.plugins.nexus.publish)
43
convention.properties
54
}
65

@@ -14,21 +13,6 @@ apiValidation {
1413
ignoredProjects += listOf("benchmark", "test-suites", "json-schema-validator-bom")
1514
}
1615

17-
val ossrhUsername: String by project.ext
18-
val ossrhPassword: String by project.ext
19-
20-
nexusPublishing {
21-
this.repositories {
22-
sonatype {
23-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
24-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
25-
26-
username.set(ossrhUsername)
27-
password.set(ossrhPassword)
28-
}
29-
}
30-
}
31-
3216
tasks.register("printKtlintVersion") {
3317
doLast {
3418
println(libs.versions.ktlint.get())

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ repositories {
99
dependencies {
1010
implementation(libs.kotlin.gradle.plugin)
1111
implementation(libs.sigstore.gradle.plugin)
12+
implementation(libs.maven.publish.gradle.plugin)
1213
}

buildSrc/src/main/kotlin/convention.publication.gradle.kts

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@ plugins {
22
`maven-publish`
33
signing
44
id("dev.sigstore.sign")
5+
id("com.vanniktech.maven.publish")
56
}
67

7-
val javadocJar by tasks.registering(Jar::class) {
8-
archiveClassifier.set("javadoc")
9-
}
10-
11-
fun getExtraString(name: String) = ext[name]?.toString()
12-
138
/**
149
* Create a service for collecting the coordinates of all artifacts that should be included in the bom.
1510
*/
@@ -38,47 +33,30 @@ bomService.coordinates
3833
},
3934
)
4035

41-
publishing {
36+
mavenPublishing {
37+
publishToMavenCentral(automaticRelease = true)
38+
signAllPublications()
4239

43-
publications.withType<MavenPublication> {
44-
// Stub javadoc.jar artifact
45-
artifact(javadocJar)
40+
pom {
41+
name.set("JSON schema validator")
42+
description.set("Multiplatform Kotlin implementation of JSON schema validator")
43+
url.set("https://github.com/OptimumCode/json-schema-validator")
4644

47-
pom {
48-
name.set("JSON schema validator")
49-
description.set("Multiplatform Kotlin implementation of JSON schema validator")
50-
url.set("https://github.com/OptimumCode/json-schema-validator")
51-
52-
licenses {
53-
license {
54-
name.set("MIT")
55-
url.set("https://opensource.org/licenses/MIT")
56-
}
57-
}
58-
developers {
59-
developer {
60-
id.set("OptimumCode")
61-
name.set("Oleg Smirnov")
62-
email.set("[email protected]")
63-
}
45+
licenses {
46+
license {
47+
name.set("MIT")
48+
url.set("https://opensource.org/licenses/MIT")
6449
}
65-
scm {
66-
url.set("https://github.com/OptimumCode/json-schema-validator")
50+
}
51+
developers {
52+
developer {
53+
id.set("OptimumCode")
54+
name.set("Oleg Smirnov")
55+
email.set("[email protected]")
6756
}
6857
}
58+
scm {
59+
url.set("https://github.com/OptimumCode/json-schema-validator")
60+
}
6961
}
7062
}
71-
72-
// otherwise, the publication fails because some task uses sign output but do not declare that
73-
tasks.withType<AbstractPublishToMaven> {
74-
mustRunAfter(tasks.withType<Sign>())
75-
}
76-
77-
signing {
78-
useInMemoryPgpKeys(
79-
getExtraString("signing.keyId"),
80-
getExtraString("signing.keys"),
81-
getExtraString("signing.password"),
82-
)
83-
sign(publishing.publications)
84-
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ kover = { id = "org.jetbrains.kotlinx.kover", version = "0.9.1" }
1818
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
1919
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.3.0" }
2020
kotlin-binaryCompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.18.0" }
21-
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }
2221

2322
[libraries]
2423
kotlin-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" }
@@ -43,6 +42,7 @@ normalize = { group = "com.doist.x", name = "normalize", version = "1.2.0" }
4342
karacteristics = { group = "io.github.optimumcode", name = "karacteristics", version = "0.0.6" }
4443
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
4544
sigstore-gradle-plugin = { module = "dev.sigstore:sigstore-gradle-sign-plugin", version = "1.3.0"}
45+
maven-publish-gradle-plugin = { module = "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin", version = "0.33.0"}
4646

4747
[bundles]
4848
openapi = ["openapi-validator", "openapi-interfaces", "openapi-jackson"]

0 commit comments

Comments
 (0)