From a118e3082f937acacedb83796dd59e23b580a2df Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Wed, 11 Sep 2024 15:46:58 +0100 Subject: [PATCH] Simplify + fix gradle commands --- .github/workflows/build.yml | 9 ++++--- .github/workflows/build_jar.yml | 32 ------------------------- .github/workflows/gradle.yml | 27 --------------------- .github/workflows/maven.yml | 15 ++++++------ .github/workflows/maven_release.yml | 1 + .github/workflows/maven_snapshot.yml | 1 + build.gradle | 35 +++++++++++++++++++++++++++- 7 files changed, 48 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/build_jar.yml delete mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 540b36a..062c8f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,13 +27,12 @@ jobs: java-version: '21' distribution: 'temurin' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v2 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Build with Gradle - uses: gradle/gradle-build-action@v3 - with: - arguments: build + run: | + ./gradlew build - uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build_jar.yml b/.github/workflows/build_jar.yml deleted file mode 100644 index 591af83..0000000 --- a/.github/workflows/build_jar.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will build the extension jar and retain the artifact. - # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - - name: Build jar - - on: [workflow_dispatch] - - jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'adopt-hotspot' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Grant execute permission for OMERO server setup script - run: chmod +x src/test/resources/omero-server/setup.sh - - name: Grant execute permission for OMERO web install pixel buffer microservice script - run: chmod +x src/test/resources/omero-web/installPixelBufferMs.sh - - name: Grant execute permission for OMERO web run pixel buffer microservice script - run: chmod +x src/test/resources/omero-web/runPixelBufferMs.sh - - name: Build with Gradle - run: ./gradlew build - - uses: actions/upload-artifact@v2 - with: - name: libs - path: build/libs - retention-days: 1 diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 3649222..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,27 +0,0 @@ -# This workflow will build a Java project with Gradle - # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - - name: Java CI with Gradle - - on: [pull_request] - - jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'adopt-hotspot' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Grant execute permission for OMERO server setup script - run: chmod +x src/test/resources/omero-server/setup.sh - - name: Grant execute permission for OMERO web install pixel buffer microservice script - run: chmod +x src/test/resources/omero-web/installPixelBufferMs.sh - - name: Grant execute permission for OMERO web run pixel buffer microservice script - run: chmod +x src/test/resources/omero-web/runPixelBufferMs.sh - - name: Build with Gradle - run: ./gradlew build diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9d65ec8..2b6f882 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,22 +19,23 @@ jobs: java-version: '21' distribution: 'temurin' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: Add release flag if input variable is set if: ${{ inputs.release }} shell: bash run: | - echo "RELEASE_FLAG='-P release=true'" >> $GITHUB_ENV + echo "RELEASE_FLAG='-Prelease'" >> $GITHUB_ENV - - name: Publish snapshot - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: publish -P toolchain=21 $RELEASE_FLAG + - name: Publish + shell: bash + run: | + ./gradlew publish -P toolchain=21 $RELEASE_FLAG env: MAVEN_USER: ${{ secrets.MAVEN_USER }} MAVEN_PASS: ${{ secrets.MAVEN_PASS }} + - uses: actions/upload-artifact@v3 if: ${{ inputs.release }} with: diff --git a/.github/workflows/maven_release.yml b/.github/workflows/maven_release.yml index 5d254f1..dc0b76c 100644 --- a/.github/workflows/maven_release.yml +++ b/.github/workflows/maven_release.yml @@ -7,5 +7,6 @@ jobs: build: name: Publish release uses: ./.github/workflows/maven.yml + secrets: inherit with: release: true diff --git a/.github/workflows/maven_snapshot.yml b/.github/workflows/maven_snapshot.yml index 28b66bd..458d45e 100644 --- a/.github/workflows/maven_snapshot.yml +++ b/.github/workflows/maven_snapshot.yml @@ -7,3 +7,4 @@ jobs: build: name: Publish snapshot uses: ./.github/workflows/maven.yml + secrets: inherit diff --git a/build.gradle b/build.gradle index 88ea409..740a8a7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { // Main gradle plugin for building a Java library id 'java-library' + id 'maven-publish' // To create a shadow/fat jar that bundle up all dependencies id 'com.github.johnrengelman.shadow' version '8.1.1' // Add JavaFX dependencies @@ -12,6 +13,7 @@ plugins { ext.moduleName = 'qupath.extension.omero' version = "0.1.1-rc1" description = "QuPath extension to support image reading using OMERO APIs." +group = 'io.github.qupath' ext.qupathVersion = gradle.ext.qupathVersion ext.qupathJavaVersion = libs.versions.jdk.get() @@ -117,4 +119,35 @@ repositories { name "unidata.releases<" url "https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases" } -} \ No newline at end of file +} + +publishing { + repositories { + maven { + name = "SciJava" + def releasesRepoUrl = uri("https://maven.scijava.org/content/repositories/releases") + def snapshotsRepoUrl = uri("https://maven.scijava.org/content/repositories/snapshots") + // Use gradle -Prelease publish + url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl + credentials { + username = System.getenv("MAVEN_USER") + password = System.getenv("MAVEN_PASS") + } + } + } + + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + licenses { + license { + name = 'Apache License v2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0' + } + } + } + } + } +}