From a7a328baa919a6bba4a05de8e6dc342cc19b71f1 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Thu, 12 Mar 2026 21:08:25 +0100 Subject: [PATCH 1/3] Initial version, with automated publishing workflow. --- .github/workflows/publish-snapshot.yml | 40 +++++++++++ README.md | 6 ++ build.gradle | 14 ++++ gradle/libs.versions.toml | 2 + .../publishing-sonatype-central.gradle | 69 +++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 .github/workflows/publish-snapshot.yml create mode 100644 gradle/scripts/publishing-sonatype-central.gradle diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..ac3217f --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,40 @@ +name: Publish snapshot + +on: + workflow_run: + workflows: ["Build and test (on commits and PRs)"] + types: [completed] + branches: [main] + +jobs: + publish: + name: Publish snapshot to Sonatype + runs-on: ubuntu-latest + + if: > + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.head_branch == 'main' && + github.repository == 'randomizedtesting/randomizedtesting-jupiter' && + secrets.NEXUS_USERNAME != '' && + secrets.NEXUS_PASSWORD != '' + + steps: + - uses: carrotsearch/infra-public/.github/actions/prepare-git-clone@master + with: + token: ${{ secrets.GH_ACCESS_TOKEN }} + + - uses: carrotsearch/infra-public/.github/actions/prepare-gradle-build@master + with: + jdk-version: '21' + + - name: Publish snapshot + run: | + VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}') + if [[ "$VERSION" == *-SNAPSHOT ]]; then + ./gradlew publishToSonatype + else + echo "Not a snapshot version ($VERSION), skipping publish." + fi + env: + ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }} diff --git a/README.md b/README.md index be3e8c6..65dfe7b 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,9 @@ for current features, their requirement descriptions and migration from junit4. See [LICENSE.txt](LICENSE.txt) to make your company's lawyer happy. See [CHANGES.txt](CHANGES.txt) for API changes and updates. + +## Snapshot artifacts and releases + +We publish snapshots to sonatype central snapshots repository. [This +document here](https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-snapshot-releases-for-your-project) +explains how to set up your project to download snapshot releases. diff --git a/build.gradle b/build.gradle index b3a48cc..9374db8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,26 @@ plugins { alias(libs.plugins.spotless) apply false + alias(libs.plugins.nexus.publish) } +apply from: file('gradle/scripts/publishing-sonatype-central.gradle') + allprojects { group = 'com.carrotsearch.randomizedtesting' version = '0.1.0-SNAPSHOT' } +nexusPublishing { + repositories { + sonatype { + nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/") + snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/") + username = findProperty("nexusUsername") ?: "" + password = findProperty("nexusPassword") ?: "" + } + } +} + subprojects { apply plugin: 'java-library' apply plugin: 'com.diffplug.spotless' diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2d22362..e53acde 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,6 +2,7 @@ assertj = "3.27.7" googleJavaFormat = "1.34.1" junit = "6.0.3" +nexus-publish = "2.0.0" spotless = "8.3.0" [libraries] @@ -12,4 +13,5 @@ junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher junit-platform-testkit = { module = "org.junit.platform:junit-platform-testkit", version.ref = "junit" } [plugins] +nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/gradle/scripts/publishing-sonatype-central.gradle b/gradle/scripts/publishing-sonatype-central.gradle new file mode 100644 index 0000000..c209547 --- /dev/null +++ b/gradle/scripts/publishing-sonatype-central.gradle @@ -0,0 +1,69 @@ +def published = [ + ":randomizedtesting-jupiter" +] + +configure(subprojects.findAll { it.path in published }) { + apply plugin: 'maven-publish' + apply plugin: 'signing' + + // Hack: do not generate or publish gradle metadata files. + tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false + } + + plugins.withType(JavaPlugin).configureEach { + java { + withSourcesJar() + withJavadocJar() + } + + publishing { + def configurePom = { + name = "${project.name}" + description = "${project.name}" + url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter' + inceptionYear = "2026" + + licenses { + license { + name = 'ASL 2.0 License' + url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter/blob/main/LICENSE.txt' + } + } + + organization { + name = "Carrot Search s.c." + url = "https://www.carrotsearch.com" + } + + developers { + developer { + id = 'dawid.weiss' + name = 'Dawid Weiss' + email = 'dawid.weiss@carrotsearch.com' + } + } + scm { + connection = 'scm:git:git@github.com:randomizedtesting/randomizedtesting-jupiter.git' + developerConnection = 'scm:git:git@github.com:randomizedtesting/randomizedtesting-jupiter.git' + url = 'https://github.com/randomizedtesting/randomizedtesting-jupiter' + } + } + + publications { + jars(MavenPublication) { + from components.java + groupId = project.group + artifactId = project.base.archivesName.get() + + pom(configurePom) + } + } + } + + signing { + required = { !project.version.endsWith('-SNAPSHOT') } + sign publishing.publications.jars + } + } +} From 12c2224267e4f01e42014a2aa45a5d278ff3ef2a Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Thu, 12 Mar 2026 21:08:53 +0100 Subject: [PATCH 2/3] Remove publishing workflow for now. --- .github/workflows/publish-snapshot.yml | 40 -------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/publish-snapshot.yml diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml deleted file mode 100644 index ac3217f..0000000 --- a/.github/workflows/publish-snapshot.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Publish snapshot - -on: - workflow_run: - workflows: ["Build and test (on commits and PRs)"] - types: [completed] - branches: [main] - -jobs: - publish: - name: Publish snapshot to Sonatype - runs-on: ubuntu-latest - - if: > - github.event.workflow_run.conclusion == 'success' && - github.event.workflow_run.head_branch == 'main' && - github.repository == 'randomizedtesting/randomizedtesting-jupiter' && - secrets.NEXUS_USERNAME != '' && - secrets.NEXUS_PASSWORD != '' - - steps: - - uses: carrotsearch/infra-public/.github/actions/prepare-git-clone@master - with: - token: ${{ secrets.GH_ACCESS_TOKEN }} - - - uses: carrotsearch/infra-public/.github/actions/prepare-gradle-build@master - with: - jdk-version: '21' - - - name: Publish snapshot - run: | - VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}') - if [[ "$VERSION" == *-SNAPSHOT ]]; then - ./gradlew publishToSonatype - else - echo "Not a snapshot version ($VERSION), skipping publish." - fi - env: - ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }} From 9a92af06c81cf530edd964c04e4897c0423ea6b5 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Thu, 12 Mar 2026 21:10:24 +0100 Subject: [PATCH 3/3] Info about local snapshots. --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 65dfe7b..1bb0d8a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ See [CHANGES.txt](CHANGES.txt) for API changes and updates. ## Snapshot artifacts and releases -We publish snapshots to sonatype central snapshots repository. [This -document here](https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-snapshot-releases-for-your-project) -explains how to set up your project to download snapshot releases. +We do not publish snapshot artifacts. If you'd like to work with a snapshot, +use gradle's composite build or install maven artifacts locally with: + +``` +./gradlew publishToMavenLocal +```