Skip to content

Migrate to vanniktech maven-publish plugin #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ jobs:
./gradlew --no-daemon --info
:json-schema-validator:assemble
:json-schema-validator-objects:assemble
publish closeAndReleaseStagingRepositories
publishToMavenCentral --no-configuration-cache
-Pversion=${{ needs.version.outputs.RELEASE_VERSION }}
-x :benchmark:benchmark
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
create_release:
runs-on: ubuntu-latest
needs:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/snapshot_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ jobs:
--info
:json-schema-validator:assemble
:json-schema-validator-objects:assemble
publish
publishToMavenCentral
-x :benchmark:benchmark
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_SECRET_KEY }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
17 changes: 0 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
alias(libs.plugins.kotlin.binaryCompatibility)
alias(libs.plugins.nexus.publish)
convention.properties
}

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

val ossrhUsername: String by project.ext
val ossrhPassword: String by project.ext

nexusPublishing {
this.repositories {
sonatype {
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))

username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}

tasks.register("printKtlintVersion") {
doLast {
println(libs.versions.ktlint.get())
Expand Down
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ repositories {
dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.sigstore.gradle.plugin)
implementation(libs.maven.publish.gradle.plugin)
}
28 changes: 0 additions & 28 deletions buildSrc/src/main/kotlin/convention.properties.gradle.kts

This file was deleted.

64 changes: 21 additions & 43 deletions buildSrc/src/main/kotlin/convention.publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ plugins {
`maven-publish`
signing
id("dev.sigstore.sign")
id("com.vanniktech.maven.publish")
}

val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}

fun getExtraString(name: String) = ext[name]?.toString()

/**
* Create a service for collecting the coordinates of all artifacts that should be included in the bom.
*/
Expand Down Expand Up @@ -38,47 +33,30 @@ bomService.coordinates
},
)

publishing {
mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()

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

pom {
name.set("JSON schema validator")
description.set("Multiplatform Kotlin implementation of JSON schema validator")
url.set("https://github.com/OptimumCode/json-schema-validator")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("OptimumCode")
name.set("Oleg Smirnov")
email.set("[email protected]")
}
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
scm {
url.set("https://github.com/OptimumCode/json-schema-validator")
}
developers {
developer {
id.set("OptimumCode")
name.set("Oleg Smirnov")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/OptimumCode/json-schema-validator")
}
}
}

// otherwise, the publication fails because some task uses sign output but do not declare that
tasks.withType<AbstractPublishToMaven> {
mustRunAfter(tasks.withType<Sign>())
}

signing {
useInMemoryPgpKeys(
getExtraString("signing.keyId"),
getExtraString("signing.keys"),
getExtraString("signing.password"),
)
sign(publishing.publications)
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ kover = { id = "org.jetbrains.kotlinx.kover", version = "0.9.1" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "12.3.0" }
kotlin-binaryCompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.18.0" }
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "2.0.0" }

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

[bundles]
openapi = ["openapi-validator", "openapi-interfaces", "openapi-jackson"]
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 4 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

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

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""


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

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

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
Expand Down
4 changes: 2 additions & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Loading