From 82749f30f86381dd8faae887068d99d5fc9efa5d Mon Sep 17 00:00:00 2001 From: arjenzhou Date: Thu, 20 Jul 2023 21:27:21 +0800 Subject: [PATCH] release: add gradle pre-v9 support; javadoc and source packaging. --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 5 ++++- build.gradle.kts | 23 ++++++++++++++--------- gradle.properties | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b72085..3bd157b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: '17' distribution: 'adopt' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 213dc23..a584d80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,15 @@ -name: Publish package to GitHub Packages +name: publish + on: release: types: [ created ] + env: GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + jobs: publish: runs-on: ubuntu-latest diff --git a/build.gradle.kts b/build.gradle.kts index 1526468..66dbe85 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -36,6 +36,7 @@ subprojects { testImplementation(platform("org.junit:junit-bom:${project.property("junit-bom.version")}")) testImplementation("org.junit.jupiter:junit-jupiter") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") } tasks { @@ -51,20 +52,23 @@ subprojects { } dependsOn(test) } - javadoc { - if (JavaVersion.current().isJava9Compatible) { - (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) - } - } + } + + java { + withJavadocJar() + withSourcesJar() } publishing { publications { - register("gpr") { + register(project.property("artifact.id") as String) { groupId = project.property("group.id") as String artifactId = project.property("artifact.id") as String + "-" + project.name version = project.property("project.version") as String from(components["java"]) + signing { + sign(this@register) + } } } repositories { @@ -79,9 +83,10 @@ subprojects { maven { name = "OSSRH" - val releasesRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") - val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl + val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") + val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + val isSnapshots = project.property("project.version").toString().endsWith("SNAPSHOT") + url = if (isSnapshots) snapshotsRepoUrl else releasesRepoUrl credentials { username = System.getenv("MAVEN_USERNAME") password = System.getenv("MAVEN_PASSWORD") diff --git a/gradle.properties b/gradle.properties index 768b966..0a85b6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group.id=com.arjenzhou artifact.id=kit -project.version=1.0.1-SNAPSHOT +project.version=1.0.1 gradle.wrapper.version=8.0 jcoco.version=0.8.9 junit-bom.version=5.9.1