From e0cc44c066284a773e469cea1c22c7e553e0d298 Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 26 Aug 2024 19:47:58 +0800 Subject: [PATCH 01/10] Migrate to com.vanniktech.maven.publish --- build-logic/build.gradle.kts | 1 + ...e.champeau.plugin-configuration.gradle.kts | 65 ++----------------- gradle.properties | 30 +++++++-- 3 files changed, 31 insertions(+), 65 deletions(-) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index f7114084..2310299b 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -24,4 +24,5 @@ repositories { dependencies { implementation("com.gradle.publish:plugin-publish-plugin:1.2.1") + implementation("com.vanniktech:gradle-maven-publish-plugin:0.29.0") } \ No newline at end of file diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index 20c3c3ec..0b39114c 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -17,10 +17,9 @@ import java.text.SimpleDateFormat import java.util.Date plugins { - `maven-publish` `java-gradle-plugin` - signing id("com.gradle.plugin-publish") + id("com.vanniktech.maven.publish") } val buildTimeAndDate: Date by lazy { @@ -58,69 +57,15 @@ tasks.jar { } } -publishing { - publications { - create("mavenJava") { - from(components["java"]) - pom { - name = "Gradle Plugin for JMH" - description = properties.getting("project_description") - url = properties.getting("project_website") - issueManagement { - system = "GitHub" - url = properties.getting("project_issues") - } - scm { - url = properties.getting("project_website") - connection = properties.getting("project_vcs").map { "scm:git:$it" } - developerConnection = "scm:git:git@github.com:melix/jmh-gradle-plugin.git" - } - licenses { - license { - name = "The Apache Software License, Version 2.0" - url = "https://www.apache.org/licenses/LICENSE-2.0.txt" - distribution = "repo" - } - } - developers { - developer { - id = "melix" - name = "Cédric Champeau" - organization { - name = "Personal" - url = "https://melix.github.io/blog" - } - } - } - } - } - } -} - -signing { - isRequired = gradle.taskGraph.allTasks.any { - it.name.startsWith("publish") - } - publishing.publications.configureEach { - sign(this) - } - sign(configurations.archives.get()) - useGpgCmd() -} - -tasks.withType().configureEach { - onlyIf { signing.isRequired } -} - gradlePlugin { - website = properties["project_website"].toString() - vcsUrl = properties["project_vcs"].toString() + website = providers.gradleProperty("POM_URL") + vcsUrl = providers.gradleProperty("POM_URL") plugins.create("jmh") { id = "me.champeau.jmh" implementationClass = "me.champeau.jmh.JMHPlugin" - displayName = properties["project_description"].toString() - description = properties["project_description"].toString() + displayName = providers.gradleProperty("POM_NAME").get() + description = providers.gradleProperty("POM_DESCRIPTION").get() tags = listOf("jmh") } } diff --git a/gradle.properties b/gradle.properties index 9cd94016..49b2ef29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,31 @@ group=me.champeau.jmh version=0.7.3-SNAPSHOT -project_description=Integrates the JMH microbenchmarking framework with Gradle, providing conventional ways to setup sources and execute micro-benchmarks with JMH. Also known as the jmh-gradle-plugin. -project_website=https://github.com/melix/jmh-gradle-plugin -project_issues=https://github.com/melix/jmh-gradle-plugin/issues -project_vcs=https://github.com/melix/jmh-gradle-plugin.git - org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.caching=true + + +GROUP=me.champeau.jmh +POM_ARTIFACT_ID=jmh-gradle-plugin +VERSION_NAME=0.7.3-SNAPSHOT + +SONATYPE_AUTOMATIC_RELEASE=true +SONATYPE_HOST=DEFAULT +RELEASE_SIGNING_ENABLED=true + +POM_NAME=Gradle Plugin for JMH +POM_DESCRIPTION=Integrates the JMH microbenchmarking framework with Gradle, providing conventional ways to setup sources and execute micro-benchmarks with JMH. Also known as the jmh-gradle-plugin. +POM_URL=https://github.com/melix/jmh-gradle-plugin + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENSE_DIST=repo + +POM_SCM_URL=https://github.com/melix/jmh-gradle-plugin +POM_SCM_CONNECTION=scm:git:git://github.com/melix/jmh-gradle-plugin.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/melix/jmh-gradle-plugin.git + +POM_DEVELOPER_ID=melix +POM_DEVELOPER_NAME=Cédric Champeau +POM_DEVELOPER_URL=https://melix.github.io/blog \ No newline at end of file From b969b5a77f51628834dbd05f0555cbb39a1df2db Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 26 Aug 2024 19:52:48 +0800 Subject: [PATCH 02/10] Add publish-snapshot workflow --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ee1a503..d0cf3dc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,3 +22,22 @@ jobs: - uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle build run: ./gradlew build + + publish-snapshot: + needs: build + runs-on: ubuntu-latest + if: github.repository_owner == 'melix' && github.ref == 'refs/heads/master' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/actions/setup-gradle@v4 + with: + cache-read-only: true + # Disable CC due to https://github.com/gradle/gradle/issues/22779 + - run: ./gradlew publish --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USER }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} \ No newline at end of file From da3adb058a8c2228e4540a343cce1055b4e15180 Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 26 Aug 2024 19:59:56 +0800 Subject: [PATCH 03/10] Add release workflow --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d234aaba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '**' + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository_owner == 'melix' + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/actions/setup-gradle@v4 + with: + cache-read-only: true + # Disable CC due to https://github.com/gradle/gradle/issues/22779 + - run: ./gradlew publish publishPlugins --no-configuration-cache + env: + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_SECRET }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USER }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }} + - name: Create release + run: | + # Extract version from tag, e.g. RELEASE_1_2_3 -> 1.2.3 + version=$(echo ${{ github.ref_name }} | sed -E 's/RELEASE_([0-9]+)_([0-9]+)_([0-9]+)/\1.\2.\3/') + echo "$version" + + gh release create ${{ github.ref_name }} --title "$version" --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 86a9f6a1ae0efe9f576741c416324f89bf095da7 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 08:27:55 +0800 Subject: [PATCH 04/10] Declare version, group, and description --- .../me.champeau.plugin-configuration.gradle.kts | 12 ++++++++---- gradle.properties | 3 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index 0b39114c..5553152c 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -22,6 +22,10 @@ plugins { id("com.vanniktech.maven.publish") } +version = providers.gradleProperty("VERSION_NAME").get() +group = providers.gradleProperty("GROUP").get() +description = providers.gradleProperty("POM_DESCRIPTION").get() + val buildTimeAndDate: Date by lazy { if ((version as String).endsWith("SNAPSHOT")) { Date(0) @@ -44,10 +48,10 @@ tasks.jar { "Build-Date" to buildDate, "Build-Time" to buildTime, // "Build-Revision" to versioning.info.commit, - "Specification-Title" to project.name, - "Specification-Version" to project.version, - "Implementation-Title" to project.name, - "Implementation-Version" to project.version + "Specification-Title" to name, + "Specification-Version" to version, + "Implementation-Title" to name, + "Implementation-Version" to version ) } metaInf { diff --git a/gradle.properties b/gradle.properties index 49b2ef29..7c1b5df5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,3 @@ -group=me.champeau.jmh -version=0.7.3-SNAPSHOT - org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 org.gradle.parallel=true org.gradle.caching=true From a9dd66a65e1db1b30cc59b904eafe1a6f000ed3d Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 09:05:36 +0800 Subject: [PATCH 05/10] Get rid of toolchain --- build.gradle.kts | 5 ++--- settings.gradle.kts | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 032af4be..e03399f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,9 +46,8 @@ dependencies { } java { - toolchain { - languageVersion = JavaLanguageVersion.of(8) - } + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 withSourcesJar() withJavadocJar() } diff --git a/settings.gradle.kts b/settings.gradle.kts index 1d7441ae..2967188b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,7 +24,6 @@ pluginManagement { plugins { id("com.gradle.develocity") version "3.18" - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } develocity { From c711c6026a18526bd7ec83fad61ce99769dfa431 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 09:06:33 +0800 Subject: [PATCH 06/10] Move java extension --- .../kotlin/me.champeau.plugin-configuration.gradle.kts | 7 +++++++ build.gradle.kts | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index 5553152c..02a84120 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -61,6 +61,13 @@ tasks.jar { } } +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + withSourcesJar() + withJavadocJar() +} + gradlePlugin { website = providers.gradleProperty("POM_URL") vcsUrl = providers.gradleProperty("POM_URL") diff --git a/build.gradle.kts b/build.gradle.kts index e03399f3..673d971d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -45,13 +45,6 @@ dependencies { testImplementation("commons-io:commons-io:2.16.1") } -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - withSourcesJar() - withJavadocJar() -} - jacoco { toolVersion = "0.8.12" } From f2078bb79aeffbf829c797d56dd049042c9bfc1e Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 09:15:02 +0800 Subject: [PATCH 07/10] Revert "Get rid of toolchain" This reverts commit a9dd66a6 --- .../kotlin/me.champeau.plugin-configuration.gradle.kts | 7 ++++--- settings.gradle.kts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index 02a84120..a28a94f6 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -14,7 +14,7 @@ * limitations under the License. */ import java.text.SimpleDateFormat -import java.util.Date +import java.util.* plugins { `java-gradle-plugin` @@ -62,8 +62,9 @@ tasks.jar { } java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } withSourcesJar() withJavadocJar() } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2967188b..1d7441ae 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,6 +24,7 @@ pluginManagement { plugins { id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } develocity { From a79fce7709601c12826d550970f123e43e7293cb Mon Sep 17 00:00:00 2001 From: Zongle Wang Date: Tue, 27 Aug 2024 22:54:49 +0800 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Robert Stupp --- .github/workflows/release.yml | 2 +- gradle.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d234aaba..4651616a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - '**' + - 'RELEASE_*' jobs: release: diff --git a/gradle.properties b/gradle.properties index 7c1b5df5..44c8ba2b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ POM_NAME=Gradle Plugin for JMH POM_DESCRIPTION=Integrates the JMH microbenchmarking framework with Gradle, providing conventional ways to setup sources and execute micro-benchmarks with JMH. Also known as the jmh-gradle-plugin. POM_URL=https://github.com/melix/jmh-gradle-plugin -POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENSE_NAME=Apache-2.0 POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENSE_DIST=repo @@ -24,5 +24,5 @@ POM_SCM_CONNECTION=scm:git:git://github.com/melix/jmh-gradle-plugin.git POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/melix/jmh-gradle-plugin.git POM_DEVELOPER_ID=melix -POM_DEVELOPER_NAME=Cédric Champeau +POM_DEVELOPER_NAME=Cédric Champeau POM_DEVELOPER_URL=https://melix.github.io/blog \ No newline at end of file From e42dcd0c48c892a97428a7ade95cd064246e7938 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 23:03:11 +0800 Subject: [PATCH 09/10] Revert import --- .../src/main/kotlin/me.champeau.plugin-configuration.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index a28a94f6..f156df41 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -14,7 +14,7 @@ * limitations under the License. */ import java.text.SimpleDateFormat -import java.util.* +import java.util.Date plugins { `java-gradle-plugin` From 49e7222e7cd15d3d51671ca643146011ab97a0e3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 27 Aug 2024 23:06:10 +0800 Subject: [PATCH 10/10] Revert toolchain change --- .../kotlin/me.champeau.plugin-configuration.gradle.kts | 8 -------- build.gradle.kts | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts index f156df41..5553152c 100644 --- a/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts +++ b/build-logic/src/main/kotlin/me.champeau.plugin-configuration.gradle.kts @@ -61,14 +61,6 @@ tasks.jar { } } -java { - toolchain { - languageVersion = JavaLanguageVersion.of(8) - } - withSourcesJar() - withJavadocJar() -} - gradlePlugin { website = providers.gradleProperty("POM_URL") vcsUrl = providers.gradleProperty("POM_URL") diff --git a/build.gradle.kts b/build.gradle.kts index 673d971d..032af4be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -45,6 +45,14 @@ dependencies { testImplementation("commons-io:commons-io:2.16.1") } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } + withSourcesJar() + withJavadocJar() +} + jacoco { toolVersion = "0.8.12" }