From 17515618d414b9e7f12cd8660b37c4ff5ee0c25d Mon Sep 17 00:00:00 2001 From: Mas Azalya Date: Fri, 16 Oct 2026 12:14:40 +0800 Subject: [PATCH] DEV-1115 Fix publish of shimmerdriverpc and refuse a 'local' publish publish failed on shimmerdriverpc with "multiple artifacts with the identical extension and classifier ('jar', 'null')": the Shadow plugin adds ShimmerJavaClass.jar (empty classifier) to components.java, and Gradle 8.14 (DEV-1013) rejects the clash. The PR dry run skips publish, so the first real release would have failed there after publishing the other two. Skip the shadow variant, which publishes the plain jar with its dependencies in the POM, as 0.11.7_beta was. Without -PreleaseVersion the version is 'local', and a hand-run `gradlew publish` would push that to GitHub Packages, where it can never be overwritten. Publishing to a remote repository now refuses 'local'; publishToMavenLocal is unaffected. Add job timeouts so a hung Gradle daemon cannot hold a runner for the default 6 hours. Checked locally (JDK 11): publishToMavenLocal -PreleaseVersion=0.0.0_test now succeeds, all three POMs and their cross-dependencies read 0.0.0_test, and shimmerdriverpc is the 140 KB thin jar. Publishing to a file repository without -PreleaseVersion fails for all three. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 4 ++++ ShimmerBluetoothManager/build.gradle | 11 +++++++++++ ShimmerDriver/build.gradle | 11 +++++++++++ ShimmerDriverPC/build.gradle | 16 ++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a34d69d8a..903707753 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,6 +56,7 @@ concurrency: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 # a hung Gradle daemon otherwise holds the runner for 6 hours permissions: contents: read packages: write @@ -166,6 +167,7 @@ jobs: matlab-jar: needs: build runs-on: ubuntu-latest + timeout-minutes: 30 # a hung Gradle daemon otherwise holds the runner for 6 hours permissions: contents: read steps: @@ -211,6 +213,7 @@ jobs: needs: [build, matlab-jar] if: github.event_name == 'workflow_dispatch' && !inputs.dry_run runs-on: ubuntu-latest + timeout-minutes: 10 permissions: contents: write # create the tag and the release env: @@ -248,6 +251,7 @@ jobs: update-matlab: needs: [build, release] runs-on: ubuntu-latest + timeout-minutes: 10 permissions: {} # writes to Shimmer-MATLAB-ID with MATLAB_REPO_TOKEN, not this repo's token env: VERSION: ${{ needs.build.outputs.version }} diff --git a/ShimmerBluetoothManager/build.gradle b/ShimmerBluetoothManager/build.gradle index c4961ecda..6bf3cb637 100644 --- a/ShimmerBluetoothManager/build.gradle +++ b/ShimmerBluetoothManager/build.gradle @@ -68,3 +68,14 @@ dependencies { // 'test.useTestNG()' to your build script. testImplementation 'junit:junit:4.12' } + +// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be +// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected. +tasks.withType(PublishToMavenRepository).configureEach { + doFirst { + if (publication.version == 'local') { + throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " + + "Release with the Release Java API workflow, or pass -PreleaseVersion.") + } + } +} diff --git a/ShimmerDriver/build.gradle b/ShimmerDriver/build.gradle index 84d17c6ea..8d62a7215 100644 --- a/ShimmerDriver/build.gradle +++ b/ShimmerDriver/build.gradle @@ -173,3 +173,14 @@ tasks.withType(Test).configureEach { } } + +// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be +// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected. +tasks.withType(PublishToMavenRepository).configureEach { + doFirst { + if (publication.version == 'local') { + throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " + + "Release with the Release Java API workflow, or pass -PreleaseVersion.") + } + } +} diff --git a/ShimmerDriverPC/build.gradle b/ShimmerDriverPC/build.gradle index 3b4ad7258..623db5df3 100644 --- a/ShimmerDriverPC/build.gradle +++ b/ShimmerDriverPC/build.gradle @@ -41,6 +41,11 @@ publishing { publications { mavenJava(MavenPublication) { from components.java + // The Shadow plugin adds ShimmerJavaClass.jar (no classifier) to components.java, where it + // collides with the plain jar and fails publish on Gradle 8. Publish the plain jar with its + // dependencies in the POM, as releases up to 0.11.7_beta did; the fat jar goes to MATLAB + // and the GitHub Release instead. + components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) { skip() } groupId = 'com.shimmerresearch' // Replace with your package's group/organization name artifactId = 'shimmerdriverpc' // Replace with the name of your package @@ -132,3 +137,14 @@ shadowJar { mergeServiceFiles() // Merges service files (if any) } + +// Without -PreleaseVersion the version is 'local', and GitHub Packages never lets a version be +// overwritten. Releases go through the Release Java API workflow; publishToMavenLocal is unaffected. +tasks.withType(PublishToMavenRepository).configureEach { + doFirst { + if (publication.version == 'local') { + throw new GradleException("Refusing to publish ${publication.artifactId} as version 'local'. " + + "Release with the Release Java API workflow, or pass -PreleaseVersion.") + } + } +}