Skip to content

Add release -SNAPSHOT dependency guard and make mavenLocal() opt-in - #123

Merged
satran004 merged 3 commits into
mainfrom
fix/release-snapshot-guard
Nov 21, 2026
Merged

satran004 merged 3 commits into
mainfrom
fix/release-snapshot-guard

Conversation

@satran004

Copy link
Copy Markdown
Member

Summary

  • Release -SNAPSHOT dependency guard (verifyNoSnapshotDependenciesInReleasePoms in build.gradle):
    • Previously, .github/workflows/release.yml only checked that the project's own version did not contain SNAPSHOT, leaving published POMs, BOM constraints, transitive classpaths, annotation processors, and buildscript plugin dependencies (such as julcVersion or cclVersion) unchecked.
    • Added verifyNoSnapshotDependenciesInReleasePoms covering all 19 published modules (including zeroj-bom-core):
      • Includes an inline parser self-check (synthetic dependency, BOM dependencyManagement, parent POM, and clean release POM) so a parser bug cannot turn the check into a silent no-op.
      • Scans every generated .pom (<version>, <parent>, <dependencies>, <dependencyManagement>) as well as resolved compileClasspath, runtimeClasspath, annotationProcessor, and buildscript:classpath components (failing closed on unresolved dependencies too).
      • Runs automatically on non-SNAPSHOT builds (and whenever -PrequireNoSnapshotDependencies=true is passed) while cleanly skipping on -SNAPSHOT project versions so snapshot publishing workflows continue uninterrupted.
      • Wired into check, nmcpZipAggregation, nmcpPublishAggregationToCentralPortal, and publishAllPublicationsToStagingRepository.
  • Workflow wiring:
    • .github/workflows/release.yml: runs verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true in Stage 0 (validate, on tag builds — fails fast in <1 s before multi-platform libblst builds) and again in Stage 2 (publish).
    • .github/workflows/ci.yml: runs verifyNoSnapshotDependenciesInReleasePoms alongside verifyDefaultModuleSurface and verifyNoBuiltinProfileDefine.
  • mavenLocal() hygiene:
    • Replaced unconditional mavenLocal() in root build.gradle with opt-in -PuseMavenLocal=true, keeping default builds and releases isolated from locally installed ~/.m2 artifacts.
    • Documented verifyNoSnapshotDependenciesInReleasePoms and -PuseMavenLocal=true in www/src/content/docs/reference/configuration.md.

Verification

  • ./gradlew verifyMavenReleasePublicationScope verifyDefaultModuleSurface verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true -PskipSigning=true --stacktrace — PASSED (19 published POMs and 74 resolved classpaths clean, 672 ms).
  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -Pversion=0.1.0-SNAPSHOT -PskipSigning=true --stacktrace — PASSED (cleanly skipped on SNAPSHOT version).
  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -Pversion=0.1.0-SNAPSHOT -PrequireNoSnapshotDependencies=true -PskipSigning=true --stacktrace — FAILED as expected with full POM & classpath violation list.
  • ./gradlew :zeroj-onchain-julc:compileJava :zeroj-api:check verifyDefaultModuleSurface verifyNoBuiltinProfileDefine verifyNoSnapshotDependenciesInReleasePoms -PskipSigning=true --stacktrace — PASSED without mavenLocal().

@satran004
satran004 requested a review from a team as a code owner November 20, 2026 17:40
@satran004

Copy link
Copy Markdown
Member Author

[reviewer1] Changes requested on 49d6c3adf5bb7ad6dec7b3b570a563c4b695f651. I ran the clean release guard (19 POMs and 74 classpaths), confirmed that a development snapshot skips by default and fails when forced, and inspected the staging task graph with Gradle’s dry run.

  1. Gate the tasks that write the staging repository. The guard depends on no publication, but only the aggregate publishAllPublicationsToStagingRepository depends on the guard. Its individual publication tasks and the guard are sibling prerequisites. I confirmed that requesting the concrete Maven publication task directly produces a task graph without the guard. Attach the dependency to each PublishToMavenRepository task targeting the staging repository so ordering holds for direct and aggregate invocations, including parallel builds. A dry-run graph check can establish this without publishing.
  2. Classify the effective Maven version consistently. The POM scanner reads literal dependency and dependency-management version text. A version supplied through a POM property, especially in a generated BOM with no consumer classpath in this build, can escape that check. Resolve local POM version properties or fail closed on unresolved expressions in release publications. Also replace the broad substring check with a shared Maven-compatible snapshot predicate: the current test misses timestamped snapshot versions and rejects ordinary qualifiers that merely contain the word. Add small negative and positive scanner fixtures for these cases. Maven snapshot classification

@satran004

Copy link
Copy Markdown
Member Author

[reviewer3] Review of head 49d6c3ad — APPROVED

Scope: build and CI wiring, release hygiene, docs.

What I verified (clean worktree at 49d6c3ad, Gradle 9.2.0, Java 25)

  • Positive run. ./gradlew verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true -PskipSigning=true --warning-mode all --rerun-tasks passes: "19 published POMs and 74 resolved classpaths clean". It raises no Gradle 9 deprecation for resolving other projects' configurations from the root task. The only warnings are the existing Groovy space-assignment ones in untouched code.

  • Negative run against a real, resolvable dependency snapshot. -PjulcVersion=0.1.0-pre21-c184298-SNAPSHOT (published on repo.bloxbean.org) with the current non-SNAPSHOT project version 0.1.0-pre13 fails with a full, readable violation list. The list covers:

    • the published POM: :zeroj-onchain-julc (pom-default.xml): dependency org.julclang:julc-stdlib / julc-ledger-api -> …-SNAPSHOT;
    • the resolved compileClasspath, runtimeClasspath and annotationProcessor configurations, including transitive julc-core and julc-vm;
    • buildscript:classpath, including org.julclang:julc-gradle-plugin. So a snapshot Julc plugin is caught as well as the library.

    This is exactly the leak the guard is meant to stop.

  • Unresolvable snapshot. -PjulcVersion=0.1.0-pre22-SNAPSHOT (no such version anywhere) fails at configuration time with "Could not find …julc-gradle-plugin". That still fails closed.

  • When the guard runs. main carries a non-SNAPSHOT version (0.1.0-pre13), so the check dependency and the new ci.yml step enforce the guard on every PR, not only at tag time. In release.yml:

    • the tag-only validate step fails fast before the blst native stage;
    • the publish stage runs the guard with -PrequireNoSnapshotDependencies=true (publish is tag-only, so forcing it cannot break a snapshot run);
    • nmcpZipAggregation, nmcpPublishAggregationToCentralPortal and every publishAllPublicationsToStagingRepository depend on the guard.

    The inline POM-parser self-check means a parser regression cannot quietly turn the guard into a no-op. pomCount < deployedProjects.size() also fails if a published project stops producing a POM.

  • mavenLocal(). It is now opt-in via -PuseMavenLocal=true and documented in reference/configuration.md. The remaining mavenLocal / publishToMavenLocal references (ReleaseNotice.astro, ADR-0045/0046/0048) are about consumers or publishing locally, and are unaffected.

Non-blocking (P3)

  1. Like the existing verifyMavenReleasePublicationScope and verifyDefaultModuleSurface guards, this task reads other projects' tasks and configurations inside doLast, so it is not configuration-cache compatible. That is fine today because CC is not enabled in gradle.properties. If CC is ever turned on, collect the POM files and resolution results as lazy inputs (ResolvedComponentResult providers) at configuration time.
  2. Plugin versions are caught today because Julc is applied through buildscript { classpath … }. A future plugin applied through plugins { id … version … } / pluginManagement resolves outside buildscript.configurations.classpath, and this scan would not see it. A comment in the task noting that limit would help the next maintainer.

Copy link
Copy Markdown

Initial automated review · Aster

Hi @satran004, thanks for the PR! 🙏 This is an automatic first check by an AI reviewer. It does not replace maintainer review and may be wrong.

Reviewed commit: 49d6c3adf5bb7ad6dec7b3b570a563c4b695f651

Issues found:

  • build.gradle:448 — Direct staging publication tasks bypass the guard, and the aggregate does not order its publication tasks after the guard. Could we make each staging PublishToMavenRepository task depend on it?

Not tested: Build scripts and tests were read only; I did not run Gradle or publish any artifacts.

@satran004

Copy link
Copy Markdown
Member Author

Addressed all review items in commit 965bf919:

  1. Concrete staging publish task gating: Attached dependsOn verifyNoSnapshotDeps to every PublishToMavenRepository task targeting the staging repository (name.endsWith('ToStagingRepository') || repository?.name == 'staging'), in addition to the aggregate publishAllPublicationsToStagingRepository task. Verified via --dry-run on :zeroj-api:publishMavenJavaPublicationToStagingRepository and :zeroj-bom-core:publishBomPublicationToStagingRepository that :verifyNoSnapshotDependenciesInReleasePoms is scheduled strictly ahead of the concrete staging publish tasks.
  2. Maven-compatible snapshot classification & POM property interpolation:
    • Replaced the broad substring check with a shared Maven 3.9.9 ArtifactUtils.isSnapshot-compatible predicate ("SNAPSHOT", "-SNAPSHOT", and timestamped ^(.*)-([0-9]{8}\.[0-9]{6})-([0-9]+)$), avoiding false rejections of ordinary qualifiers like 1.0.0-snapshotter.
    • Added bounded POM <properties> / project.version / project.parent.version interpolation and fail-closed rejection of any unresolved ${...} expression in release POMs.
    • Expanded the inline scanner self-check with positive and negative fixtures covering -SNAPSHOT, timestamped snapshots, property-interpolated BOM snapshots, unresolved ${...} expressions, parent POM snapshots, resolved release properties, and non-snapshot qualifiers containing the word snapshot.
  3. Buildscript scan scope comment: Added a clarifying comment noting that project.buildscript.configurations.classpath covers buildscript classpath plugins (such as julc-gradle-plugin), while plugins {} / pluginManagement plugins are pinned in plugin blocks on the settings classpath. Also unified UnresolvedDependencyResult checking across both module and buildscript classpaths.

Verification (965bf919):

  • ./gradlew :zeroj-api:publishMavenJavaPublicationToStagingRepository :zeroj-bom-core:publishBomPublicationToStagingRepository -PstagingRepository=/tmp/zeroj-dryrun-stage -PskipSigning=true --dry-run — :verifyNoSnapshotDependenciesInReleasePoms precedes both concrete staging tasks.
  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true -PskipSigning=true --stacktrace — PASSED (19 published POMs and 74 resolved classpaths clean, 450 ms).

@satran004

Copy link
Copy Markdown
Member Author

[reviewer1] Changes requested on 965bf919514ee52c2b117fbc8d9979e81fa673ed for the snapshot predicate. The staging task dependencies are fixed: I confirmed the guard precedes the concrete API and BOM publication tasks in Gradle’s dry-run graph. The clean check passed for 19 POMs and 74 classpaths, the conventional development snapshot skipped, and the forced snapshot check failed as expected.

Maven 3.9.9 checks the last eight characters case-insensitively for SNAPSHOT, then checks its timestamp pattern. The new predicate still requires uppercase and either the exact literal or a preceding hyphen. As a result it can classify a Maven snapshot dependency as clean, including a conventional mixed-case suffix. Match the reference suffix comparison exactly and add a mixed-case fixture alongside the existing clean snapshotter control. Also keep the decision to skip the entire guard scoped to the project's intentional development/snapshot publication mode: sharing a broader dependency predicate for that decision could skip a direct release staging check on a version the rest of this build treats as a release. Maven 3.9.9 ArtifactUtils.isSnapshot

@satran004

Copy link
Copy Markdown
Member Author

[reviewer3] Re-review of head 965bf919 — CHANGES REQUESTED (one small regression in the new snapshot predicate)

What I verified

  • Staging gate. --dry-run of :zeroj-api:publishMavenJavaPublicationToStagingRepository and :zeroj-bom-core:publishAllPublicationsToStagingRepository (with -PstagingRepository=…) shows :verifyNoSnapshotDependenciesInReleasePoms scheduled before both concrete staging tasks. snapshot.yml / bloxbean-snapshot*.yml publish SNAPSHOT versions, where the unforced guard skips by design, so the new gate does not break snapshot publishing.
  • Positive run. The forced run passes: 19 POMs and 74 classpaths clean.
  • Negative run. -PjulcVersion=0.1.0-pre21-c184298-SNAPSHOT still fails with the full POM, classpath and buildscript violation list.
  • New handling. Property interpolation (<properties>, project.version, project.parent.version, bounded depth), fail-closed rejection of unresolved ${…}, the shared scanConfiguration (unresolved-dependency check now also covers the buildscript classpaths), and the plugins {} scope comment all look right.

Blocking: isMavenSnapshot does not match Maven and is weaker than round 1

The new comment says the predicate "Matches org.apache.maven.artifact.ArtifactUtils.isSnapshot (Maven 3.9.9)". It does not. Maven compares the SNAPSHOT suffix case-insensitively (regionMatches(true, …)) and does not require a leading -. I checked against the real class (maven-artifact-3.9.8, ArtifactUtils.isSnapshot):

version Maven isSnapshot PR isMavenSnapshot
1.0-SNAPSHOT true true
1.0-snapshot true false
1.0SNAPSHOT true false
1.0.snapshot true false
SNAPSHOT true true
0.1.0-20261120.174000-1 true true
1.0.0-snapshotter false false

Round 1 (49d6c3ad) used a case-insensitive contains('SNAPSHOT') and caught all three of the bold rows. This round lets them through, both in the POM scan and in the resolved-component scan, even though Maven consumers treat them as mutable snapshots.

Suggested fix: make the suffix check exactly Maven's:

def SNAP = 'SNAPSHOT'
def isMavenSnapshot = { String ver ->
    ver != null && !ver.isEmpty() && (
        (ver.length() >= SNAP.length()
            && ver.regionMatches(true, ver.length() - SNAP.length(), SNAP, 0, SNAP.length()))
        || timestampedSnapshotPattern.matcher(ver).matches())
}

Then add 1.0-snapshot and 1.0SNAPSHOT as negative self-check fixtures. Keep 1.0.0-snapshotter as the clean control.

No other findings.

@satran004

Copy link
Copy Markdown
Member Author

Addressed Round 2 review items in commit 7d78aa4f:

  1. Exact Maven 3.9.9 ArtifactUtils.isSnapshot suffix predicate: Switched isMavenSnapshot to case-insensitive terminal SNAPSHOT matching via regionMatches(true, ver.length() - snapSuffix.length(), snapSuffix, 0, snapSuffix.length()) plus the timestamped pattern, and added 1.0-snapshot and 1.0SNAPSHOT negative fixtures to the inline self-check while retaining 1.0.0-snapshotter as the clean control.
  2. Build-scoped development-mode skip convention: Scoped the unforced guard skip strictly to rootVersion.endsWith('-SNAPSHOT') (matching subprojects version rewriting and snapshot.yml), so non-conventional Maven snapshot versions (such as 0.1.0-snapshot or timestamped versions that the rest of the build treats as releases) run and fail the guard.

Verification (7d78aa4f):

  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true -PskipSigning=true — PASSED (19 published POMs and 74 resolved classpaths clean, 479 ms)
  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -Pversion=0.1.0-SNAPSHOT -PskipSigning=true — PASSED (skips cleanly for dev *-SNAPSHOT mode)
  • ./gradlew verifyNoSnapshotDependenciesInReleasePoms -Pversion=0.1.0-snapshot -PskipSigning=true — FAILED as expected (does not skip; flags all 0.1.0-snapshot POM & classpath entries)

@satran004

Copy link
Copy Markdown
Member Author

[reviewer1] Approved on 7d78aa4f8a65c19cc1dda05812cccaffdecd8232. I verified that the dependency predicate matches Maven 3.9.9’s terminal, case-insensitive snapshot check and timestamp rule, while the automatic development-build skip uses the project’s narrower convention. A clean release passed for 19 POMs and 74 classpaths. Separate runs rejected mixed-case and timestamped snapshot project versions and skipped the conventional development snapshot. Gradle dry runs placed the guard before both the concrete API and BOM staging writes.

@satran004

Copy link
Copy Markdown
Member Author

[reviewer3] Re-review of head 7d78aa4f — APPROVED

The round-2 item is resolved. isMavenSnapshot now matches Maven ArtifactUtils.isSnapshot: a case-insensitive regionMatches on a terminal SNAPSHOT with no hyphen required, or the timestamped pattern. That is the same truth table I checked against maven-artifact 3.9.8. The self-checks now include 1.0-snapshot and 1.0SNAPSHOT as negatives, with 1.0.0-snapshotter kept as the clean control. The automatic skip is narrowed to the build's own *-SNAPSHOT development convention.

Verified at 7d78aa4f:

Run Result
forced, -PrequireNoSnapshotDependencies=true passes: 19 published POMs and 74 resolved classpaths clean
-Pversion=0.1.0-SNAPSHOT skips with the development-snapshot message
-Pversion=0.1.0-snapshot (unforced) fails: the guard runs and rejects the non-conventional Maven snapshot

The staging-task gating and the real Julc-snapshot negative were verified in the previous round, and this diff does not touch them.

No further findings.

@satran004
satran004 merged commit fecf354 into main Nov 21, 2026
7 of 8 checks passed
@satran004
satran004 deleted the fix/release-snapshot-guard branch November 21, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants