From 9978a56dc10c2c622d3a67d8e18000dc4bbb552f Mon Sep 17 00:00:00 2001 From: cooked Date: Wed, 16 Oct 2024 12:11:51 +0100 Subject: [PATCH 1/4] Upgrade to Gradle 8.10.2 and Add JReleaser Co-authored-by: Daniel Milnes Co-authored-by: DJ --- build.gradle | 89 ++++++++++++------------ gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/build.gradle b/build.gradle index 6db9248..9e4d328 100644 --- a/build.gradle +++ b/build.gradle @@ -15,12 +15,14 @@ */ plugins { + id 'java' id 'java-library' id 'maven-publish' id 'signing' id 'checkstyle' id 'idea' id "biz.aQute.bnd.builder" version "6.3.1" + id 'org.jreleaser' version '1.14.0' } @@ -33,14 +35,8 @@ ext { fullName = 'Disruptor-Proxy' fullDescription = 'A utility for generating Disruptor-backed proxies for easy execution serialisation' teamName = 'LMAX Development Team' - siteUrl = 'http://github.com/LMAX-Exchange/disruptor-proxy' + siteUrl = 'https://github.com/LMAX-Exchange/disruptor-proxy' sourceUrl = 'git@github.com:LMAX-Exchange/disruptor-proxy.git' - - javaCompilerExecutable = System.env['JAVA_HOME'] ? System.env['JAVA_HOME'] + '/bin/javac' : 'javac' - - if (!project.hasProperty('sonatypeUrl')) sonatypeUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2' - if (!project.hasProperty('sonatypeUsername')) sonatypeUsername = '' - if (!project.hasProperty('sonatypePassword')) sonatypePassword = '' } repositories { @@ -55,40 +51,26 @@ dependencies { } -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 - -jar { - manifest.attributes('Built-By': System.properties['user.name'], - 'Bundle-Name': fullName, - 'Bundle-Vendor': teamName, - 'Bundle-Description': fullDescription, - 'Bundle-DocURL': siteUrl) +java { + toolchain { + languageVersion = JavaLanguageVersion.of(11) + } + withJavadocJar() + withSourcesJar() } checkstyle { toolVersion = 6.3 } -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar, javadocJar -} - publishing { publications { disruptor(MavenPublication) { from components.java + groupId = 'com.lmax' + artifactId = 'disruptor-proxy' + pom { name = project.ext.fullName description = project.ext.fullDescription @@ -97,44 +79,63 @@ publishing { scm { url = "scm:${project.ext.sourceUrl}" connection = "scm:${project.ext.sourceUrl}" + developerConnection = "scm:${project.ext.sourceUrl}" } licenses { license { - name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + name = 'Apache-2.0' + url = 'https://spdx.org/licenses/Apache-2.0.html' } } developers { developer { - id = 'team' + id = 'LMAX Group Open Source' name = teamName - email = 'disruptor-proxy@googlegroups.com' + email = 'opensource@lmax.com' } } } } } + repositories { maven { - url project.hasProperty('sonatypeUrl') ? project['sonatypeUrl'] : 'https://oss.sonatype.org/service/local/staging/deploy/maven2' - - credentials { - username = project.hasProperty('sonatypeUsername') ? project['sonatypeUsername'] : 'fake-user' - password = project.hasProperty('sonatypePassword') ? project['sonatypePassword'] : 'fake-password' - } + url = layout.buildDirectory.dir('staging-deploy') } } } -signing { - sign publishing.publications.disruptor +jreleaser { + files { + active = 'ALWAYS' + glob { + pattern = 'build/staging-deploy/**/*.jar' + pattern = 'build/staging-deploy/**/*.pom' + pattern = 'build/staging-deploy/**/*.module' + } + } + signing { + active = 'ALWAYS' + armored = true + mode = 'MEMORY' + } + deploy { + maven { + mavenCentral { + sonatype { + active = 'ALWAYS' + url = 'https://central.sonatype.com/api/v1/publisher' + stagingRepository('build/staging-deploy') + applyMavenCentralRules = true + } + } + } + } } - - class Version { int major, minor = 0, revision = 0 boolean snapshot diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f398c33..5c40527 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 5258394fe842d83d5ae3120937328f89b11fc792 Mon Sep 17 00:00:00 2001 From: cooked Date: Wed, 16 Oct 2024 12:13:49 +0100 Subject: [PATCH 2/4] Enable Dependency Submission in CI Co-authored-by: Daniel Milnes Co-authored-by: DJ --- .github/workflows/ci.yml | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 693b178..0e84426 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,63 @@ jobs: name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v2 + - name: Set up java uses: actions/setup-java@v1 with: java-version: ${{ matrix.java }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Build with Gradle run: ./gradlew build + + dependency-submission: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 + + javadoc: + runs-on: ubuntu-latest + permissions: + contents: write + pages: write + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Build Javadoc + run: ./gradlew javadoc + + - name: Deploy Pages Content + uses: JamesIves/github-pages-deploy-action@v4.6.4 + # https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable + if: ${{ always() && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }} + with: + folder: build/docs/javadoc \ No newline at end of file From 62e1498330c6f42052a3ffe18ff9f73932ca4379 Mon Sep 17 00:00:00 2001 From: cooked Date: Wed, 16 Oct 2024 12:19:19 +0100 Subject: [PATCH 3/4] Add CI Job for Maven Central Publishing Co-authored-by: Daniel Milnes Co-authored-by: DJ --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ build.gradle | 15 +++-------- 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..98f3bba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Publish Release Artifacts +on: + release: + types: [ created ] + +permissions: + contents: write + packages: write + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Set Gradle App Version to ${{ github.event.release.tag_name }} + run: sed -i "s/version = '.*'/version = '${{ github.event.release.tag_name }}'/g" build.gradle + - name: Publish package + uses: gradle/gradle-build-action@v2.11.1 + with: + arguments: publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish package to Maven Central + uses: gradle/gradle-build-action@v2.11.1 + with: + arguments: jreleaserFullRelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_TOKEN }} + JRELEASER_GPG_SECRET_KEY: "${{ secrets.JRELEASER_GPG_SECRET_KEY }}" + JRELEASER_GPG_PUBLIC_KEY: "${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}" + JRELEASER_GPG_PASSPHRASE: "${{ secrets.JRELEASER_GPG_PASSPHRASE }}" + JRELEASER_GITHUB_TOKEN: ${{ github.token }} + JRELEASER_MAVENCENTRAL_STAGE: "FULL" + - name: Add Artifact to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: build/libs/disruptor-proxy-*.jar diff --git a/build.gradle b/build.gradle index 9e4d328..31bdf85 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,8 @@ plugins { defaultTasks 'checkstyleTest', 'checkstyleMain', 'build' group = 'com.lmax' -version = new Version(major: 2, minor: 2, revision: 0) +// The below is updated by CI during the release +version = '1.0.0' ext { fullName = 'Disruptor-Proxy' @@ -130,18 +131,10 @@ jreleaser { url = 'https://central.sonatype.com/api/v1/publisher' stagingRepository('build/staging-deploy') applyMavenCentralRules = true + closeRepository = true + releaseRepository = true } } } } } - -class Version { - int major, minor = 0, revision = 0 - boolean snapshot - String stage - - String toString() { - "$major.$minor.$revision${stage ? '.' + stage : ''}${snapshot ? '-SNAPSHOT' : ''}" - } -} From 1cfe9b2d7c2036a40c5b82b27dc2079aa3390c28 Mon Sep 17 00:00:00 2001 From: cooked Date: Wed, 16 Oct 2024 12:21:18 +0100 Subject: [PATCH 4/4] Remove unused JReleaser Properties Co-authored-by: Daniel Milnes Co-authored-by: DJ --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index 31bdf85..bb0a7bd 100644 --- a/build.gradle +++ b/build.gradle @@ -131,8 +131,6 @@ jreleaser { url = 'https://central.sonatype.com/api/v1/publisher' stagingRepository('build/staging-deploy') applyMavenCentralRules = true - closeRepository = true - releaseRepository = true } } }