Skip to content

Commit fad4222

Browse files
authored
Migrate to vanniktech maven-publish plugin (#315)
Resolves #314
1 parent f0de3c0 commit fad4222

File tree

11 files changed

+42
-109
lines changed

11 files changed

+42
-109
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ jobs:
7373
./gradlew --no-daemon --info
7474
:json-schema-validator:assemble
7575
:json-schema-validator-objects:assemble
76-
publish closeAndReleaseStagingRepositories
76+
publishToMavenCentral --no-configuration-cache
7777
-Pversion=${{ needs.version.outputs.RELEASE_VERSION }}
7878
-x :benchmark:benchmark
7979
env:
80-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
81-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
82-
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
83-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
84-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
80+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
81+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
82+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }}
83+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
84+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
8585
create_release:
8686
runs-on: ubuntu-latest
8787
needs:

.github/workflows/snapshot_release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ jobs:
6060
--info
6161
:json-schema-validator:assemble
6262
:json-schema-validator-objects:assemble
63-
publish
63+
publishToMavenCentral
6464
-x :benchmark:benchmark
6565
env:
66-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
67-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
68-
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
69-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
70-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
66+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
67+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
68+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }}
69+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
70+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}

build.gradle.kts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
plugins {
22
alias(libs.plugins.kotlin.binaryCompatibility)
3-
alias(libs.plugins.nexus.publish)
4-
convention.properties
53
}
64

75
allprojects {
@@ -14,21 +12,6 @@ apiValidation {
1412
ignoredProjects += listOf("benchmark", "test-suites", "json-schema-validator-bom")
1513
}
1614

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-
3215
tasks.register("printKtlintVersion") {
3316
doLast {
3417
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.properties.gradle.kts

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

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("oleg31101996@gmail.com")
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("oleg31101996@gmail.com")
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"]

gradle/wrapper/gradle-wrapper.jar

260 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ done
8686
# shellcheck disable=SC2034
8787
APP_BASE_NAME=${0##*/}
8888
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89-
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90-
' "$PWD" ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
9190

9291
# Use the maximum available, or set MAX_FD != -1 to use that value.
9392
MAX_FD=maximum
@@ -115,7 +114,7 @@ case "$( uname )" in #(
115114
NONSTOP* ) nonstop=true ;;
116115
esac
117116

118-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
119118

120119

121120
# Determine the Java command to use to start the JVM.
@@ -206,15 +205,15 @@ fi
206205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207206

208207
# Collect all arguments for the java command:
209-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210209
# and any embedded shellness will be escaped.
211210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212211
# treated as '${Hostname}' itself on the command line.
213212

214213
set -- \
215214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
216215
-classpath "$CLASSPATH" \
217-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
218217
"$@"
219218

220219
# Stop when "xargs" is not available.

0 commit comments

Comments
 (0)