From 49d6c3adf5bb7ad6dec7b3b570a563c4b695f651 Mon Sep 17 00:00:00 2001 From: Satya Date: Sat, 21 Nov 2026 01:39:20 +0800 Subject: [PATCH 1/3] Add release -SNAPSHOT dependency guard and make mavenLocal() opt-in --- .github/workflows/ci.yml | 4 +- .github/workflows/release.yml | 8 +- build.gradle | 178 +++++++++++++++++- .../content/docs/reference/configuration.md | 2 + 4 files changed, 187 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd36d383..f564d8a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,8 +35,8 @@ jobs: - name: Build and test run: ./gradlew build -PskipSigning=true --stacktrace - - name: Assert the default graph has no assurance/benchmark/removed-provider edge - run: ./gradlew verifyDefaultModuleSurface verifyNoBuiltinProfileDefine --stacktrace + - name: Assert module boundaries and release POMs have no -SNAPSHOT dependencies + run: ./gradlew verifyDefaultModuleSurface verifyNoBuiltinProfileDefine verifyNoSnapshotDependenciesInReleasePoms -PskipSigning=true --stacktrace - name: Upload test reports if: always() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0eed60f9..ef390b47 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -113,6 +113,10 @@ jobs: echo "Version $VERSION (final: $IS_FINAL), Maven Central: $MAVEN_CENTRAL_PUBLISH," \ "BloxBean repository: $BLOXBEAN_REPO_PUBLISH, GitHub release: ${GITHUB_RELEASE:-false}" + - name: Assert release POMs and classpaths contain no -SNAPSHOT dependencies + if: github.ref_type == 'tag' + run: ./gradlew verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true -PskipSigning=true --stacktrace + # ================================================================ # Stage 1: Build libblst from source for every supported platform # (pinned tag in zeroj-blst/scripts/build-blst.sh) so released jars @@ -268,8 +272,8 @@ jobs: - name: Build and test run: ./gradlew build --stacktrace - - name: Assert the default graph has no assurance/benchmark/removed-provider edge - run: ./gradlew verifyDefaultModuleSurface verifyNoBuiltinProfileDefine --stacktrace + - name: Assert module boundaries and release POMs have no -SNAPSHOT dependencies + run: ./gradlew verifyDefaultModuleSurface verifyNoBuiltinProfileDefine verifyNoSnapshotDependenciesInReleasePoms -PrequireNoSnapshotDependencies=true --stacktrace # Learns the artifactIds this build owns; unsigned, its staged files are discarded. - name: Discover the Maven publications diff --git a/build.gradle b/build.gradle index a54bccff..0edf899f 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,10 @@ plugins { allprojects { repositories { mavenCentral() - mavenLocal() + // Opt-in only: keep default builds and releases isolated from locally published ~/.m2 artifacts. + if (rootProject.providers.gradleProperty('useMavenLocal').map { it.equalsIgnoreCase('true') }.getOrElse(false)) { + mavenLocal() + } maven { url = uri("https://central.sonatype.com/repository/maven-snapshots") content { @@ -274,6 +277,179 @@ tasks.matching { dependsOn 'verifyMavenReleasePublicationScope' } +// === Release -SNAPSHOT dependency guard ========================================================= +// Fails any non-SNAPSHOT release (or any run with -PrequireNoSnapshotDependencies=true) if a +// published Maven POM, resolved compile/runtime/annotationProcessor classpath, or buildscript +// plugin classpath references a -SNAPSHOT artifact. +def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInReleasePoms') { + group = 'verification' + description = 'Asserts published release POMs and resolved release classpaths contain no -SNAPSHOT dependencies.' + + def forceCheck = providers.gradleProperty('requireNoSnapshotDependencies') + .map { it.equalsIgnoreCase('true') } + .getOrElse(false) + def deployedProjects = centralDeploymentProjects + + doLast { + def findSnapshotVersionsInPom = { String xmlText, String sourceLabel -> + def hits = [] + def pom = new groovy.xml.XmlSlurper(false, false).parseText(xmlText) + def checkVersion = { String coord, String ver -> + if (ver != null && ver.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { + hits << "${sourceLabel}: ${coord} -> ${ver}" + } + } + checkVersion('project', pom.version?.text()?.trim()) + if (pom.parent.size() > 0) { + def parentCoord = "${pom.parent.groupId.text().trim()}:${pom.parent.artifactId.text().trim()}" + checkVersion("parent ${parentCoord}", pom.parent.version?.text()?.trim()) + } + def inspectDeps = { depsNode, String section -> + depsNode.dependency.each { dep -> + def coord = "${dep.groupId.text().trim()}:${dep.artifactId.text().trim()}" + checkVersion("${section} ${coord}", dep.version?.text()?.trim()) + } + } + inspectDeps(pom.dependencies, 'dependency') + inspectDeps(pom.dependencyManagement.dependencies, 'dependencyManagement') + return hits + } + + // Self-check the POM scanner so a parser regression cannot turn this guard into a silent no-op. + def badDepPom = ''' + org.zerojsample0.1.0 + org.julclangjulc-stdlib0.1.0-pre21-SNAPSHOT + ''' + def badBomPom = ''' + org.zerojsample-bom0.1.0 + org.zerojzeroj-api0.1.0-SNAPSHOT + ''' + def badParentPom = ''' + org.exampleparent1.0-SNAPSHOT + org.zerojsample0.1.0 + ''' + def cleanPom = ''' + org.zerojsample0.1.0-pre13 + org.julclangjulc-stdlib0.1.0-pre22 + ''' + if (findSnapshotVersionsInPom(badDepPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badBomPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badParentPom, 'self-check').isEmpty() + || !findSnapshotVersionsInPom(cleanPom, 'self-check').isEmpty()) { + throw new GradleException('Release -SNAPSHOT POM guard self-check failed.') + } + + def rootVersion = rootProject.version.toString() + def isSnapshotBuild = rootVersion.toUpperCase(Locale.ROOT).endsWith('SNAPSHOT') + if (isSnapshotBuild && !forceCheck) { + logger.lifecycle("Skipping release -SNAPSHOT dependency guard for SNAPSHOT project version ${rootVersion}.") + return + } + + def violations = [] + int pomCount = 0 + int configCount = 0 + + if (isSnapshotBuild) { + violations << "rootProject version is SNAPSHOT: ${rootVersion}" + } + + deployedProjects.each { candidate -> + def pomTasks = candidate.tasks.withType(GenerateMavenPom).toList() + if (pomTasks.isEmpty()) { + violations << "${candidate.path}: declares no GenerateMavenPom task" + } + pomTasks.each { pomTask -> + File pomFile = pomTask.destination + if (!pomFile.isFile()) { + violations << "${candidate.path}: expected generated POM missing at ${pomFile}" + } else { + pomCount++ + violations.addAll(findSnapshotVersionsInPom( + pomFile.getText('UTF-8'), + "${candidate.path} (${pomFile.name})")) + } + } + + ['compileClasspath', 'runtimeClasspath', 'annotationProcessor'].each { cfgName -> + def cfg = candidate.configurations.findByName(cfgName) + if (cfg != null && cfg.canBeResolved) { + configCount++ + def result = cfg.incoming.resolutionResult + result.allDependencies.each { dep -> + if (dep instanceof org.gradle.api.artifacts.result.UnresolvedDependencyResult) { + violations << "${candidate.path} [${cfgName}]: unresolved dependency ${dep.requested} (${dep.failure.message})" + } + } + result.allComponents.each { comp -> + def mv = comp.moduleVersion + if (mv != null && mv.version != null + && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { + violations << "${candidate.path} [${cfgName}]: ${mv.group}:${mv.name}:${mv.version}" + } + } + } + } + + def bsCfg = candidate.buildscript.configurations.findByName('classpath') + if (bsCfg != null && bsCfg.canBeResolved) { + configCount++ + bsCfg.incoming.resolutionResult.allComponents.each { comp -> + def mv = comp.moduleVersion + if (mv != null && mv.version != null + && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { + violations << "${candidate.path} [buildscript:classpath]: ${mv.group}:${mv.name}:${mv.version}" + } + } + } + } + + def rootBsCfg = rootProject.buildscript.configurations.findByName('classpath') + if (rootBsCfg != null && rootBsCfg.canBeResolved) { + configCount++ + rootBsCfg.incoming.resolutionResult.allComponents.each { comp -> + def mv = comp.moduleVersion + if (mv != null && mv.version != null + && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { + violations << ": [buildscript:classpath]: ${mv.group}:${mv.name}:${mv.version}" + } + } + } + + if (pomCount < deployedProjects.size()) { + violations << "Scanned only ${pomCount} POMs across ${deployedProjects.size()} published projects" + } + + if (!violations.isEmpty()) { + throw new GradleException( + "Release publications must not depend on -SNAPSHOT artifacts:\n - " + + violations.unique().sort().join('\n - ')) + } + logger.lifecycle( + "Release -SNAPSHOT dependency guard passed: ${pomCount} published POMs and ${configCount} resolved classpaths clean.") + } +} + +gradle.projectsEvaluated { + verifyNoSnapshotDeps.configure { task -> + centralDeploymentProjects.each { candidate -> + task.dependsOn(candidate.tasks.withType(GenerateMavenPom)) + } + } +} + +tasks.named('check') { dependsOn verifyNoSnapshotDeps } +tasks.matching { + it.name in ['nmcpZipAggregation', 'nmcpPublishAggregationToCentralPortal'] +}.configureEach { + dependsOn verifyNoSnapshotDeps +} +allprojects { candidate -> + candidate.tasks.matching { it.name == 'publishAllPublicationsToStagingRepository' }.configureEach { + dependsOn verifyNoSnapshotDeps + } +} + // === ADR-0044 structural guard ================================================================= // Asserts that the default (stable) product graph never gains an edge to an assurance, benchmark, // incubator, or removed module, and that the boundaries the ADR keeps apart stay apart. Runs in CI, diff --git a/www/src/content/docs/reference/configuration.md b/www/src/content/docs/reference/configuration.md index 4f39e501..5eed054c 100644 --- a/www/src/content/docs/reference/configuration.md +++ b/www/src/content/docs/reference/configuration.md @@ -144,6 +144,8 @@ These only matter when you build the ZeroJ repository itself. Use the Gradle wra | `-PrequireSnarkjs` | Makes the snarkjs interop suites in `zeroj-integration-tests` **fail** instead of skip when snarkjs 0.7.6 is missing (sets `zeroj.assurance.requireSnarkjs=true`) | | `./gradlew :zeroj-integration-tests:e2eTest` | Runs `@Tag("e2e")` tests: Yaci DevKit on-chain flows and snarkjs proving. They skip gracefully when Yaci DevKit (`localhost:8080`) or snarkjs is absent. | | `./gradlew verifyDefaultModuleSurface` | Checks the stable module graph has no edge into assurance, benchmark or removed modules | +| `./gradlew verifyNoSnapshotDependenciesInReleasePoms` | Fails non-SNAPSHOT builds (or any run with `-PrequireNoSnapshotDependencies=true`) if any published POM or resolved classpath references a `-SNAPSHOT` dependency | +| `-PuseMavenLocal=true` | Opt-in local `~/.m2` repository lookup (off by default so builds and releases stay isolated from local Maven installs) | ```bash ./gradlew -PincludeAssurance :zeroj-bls12381-wasm:test :zeroj-bbs-wasm:test :zeroj-bbs:test From 965bf919514ee52c2b117fbc8d9979e81fa673ed Mon Sep 17 00:00:00 2001 From: Satya Date: Sat, 21 Nov 2026 01:45:14 +0800 Subject: [PATCH 2/3] Address PR #123 review: gate concrete staging publish tasks and Maven snapshot/property checks --- build.gradle | 153 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 102 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index 0edf899f..6713e0da 100644 --- a/build.gradle +++ b/build.gradle @@ -280,7 +280,8 @@ tasks.matching { // === Release -SNAPSHOT dependency guard ========================================================= // Fails any non-SNAPSHOT release (or any run with -PrequireNoSnapshotDependencies=true) if a // published Maven POM, resolved compile/runtime/annotationProcessor classpath, or buildscript -// plugin classpath references a -SNAPSHOT artifact. +// plugin classpath references a Maven snapshot artifact (including timestamped snapshots or +// property-interpolated / unresolved version expressions). def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInReleasePoms') { group = 'verification' description = 'Asserts published release POMs and resolved release classpaths contain no -SNAPSHOT dependencies.' @@ -291,18 +292,62 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease def deployedProjects = centralDeploymentProjects doLast { + // Matches org.apache.maven.artifact.ArtifactUtils.isSnapshot (Maven 3.9.9): + // literal "SNAPSHOT", suffix "-SNAPSHOT", or timestamped "-YYYYMMDD.HHMMSS-". + def timestampedSnapshotPattern = ~/^(.*)-([0-9]{8}\.[0-9]{6})-([0-9]+)$/ + def isMavenSnapshot = { String ver -> + if (ver == null || ver.isEmpty()) return false + return ver == 'SNAPSHOT' + || ver.endsWith('-SNAPSHOT') + || timestampedSnapshotPattern.matcher(ver).matches() + } + + def resolvePomProperties = { String raw, Map props -> + if (raw == null) return null + String current = raw.trim() + // Bounded expansion to handle chained properties without looping on cycles. + for (int depth = 0; depth < 8 && current.contains('${'); depth++) { + String next = current.replaceAll(/\$\{([^}]+)\}/) { match, key -> + props.containsKey(key) ? java.util.regex.Matcher.quoteReplacement(props[key]) : java.util.regex.Matcher.quoteReplacement(match) + } + if (next == current) break + current = next + } + return current + } + def findSnapshotVersionsInPom = { String xmlText, String sourceLabel -> def hits = [] def pom = new groovy.xml.XmlSlurper(false, false).parseText(xmlText) - def checkVersion = { String coord, String ver -> - if (ver != null && ver.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { - hits << "${sourceLabel}: ${coord} -> ${ver}" + Map props = new LinkedHashMap<>() + pom.properties.children().each { prop -> + props[prop.name()] = prop.text().trim() + } + String parentVer = pom.parent.size() > 0 ? pom.parent.version?.text()?.trim() : null + String projectVer = pom.version?.text()?.trim() + if (parentVer) { + props['project.parent.version'] = parentVer + props['parent.version'] = parentVer + } + String effectiveProjectVer = projectVer ?: parentVer + if (effectiveProjectVer) { + props['project.version'] = effectiveProjectVer + props['version'] = effectiveProjectVer + } + + def checkVersion = { String coord, String rawVer -> + if (rawVer == null || rawVer.isEmpty()) return + String resolved = resolvePomProperties(rawVer, props) + if (resolved.contains('${')) { + hits << "${sourceLabel}: ${coord} -> unresolved version expression '${rawVer}' (resolved: '${resolved}')" + } else if (isMavenSnapshot(resolved)) { + hits << "${sourceLabel}: ${coord} -> ${resolved}" + (resolved != rawVer ? " (from ${rawVer})" : '') } } - checkVersion('project', pom.version?.text()?.trim()) + checkVersion('project', effectiveProjectVer) if (pom.parent.size() > 0) { def parentCoord = "${pom.parent.groupId.text().trim()}:${pom.parent.artifactId.text().trim()}" - checkVersion("parent ${parentCoord}", pom.parent.version?.text()?.trim()) + checkVersion("parent ${parentCoord}", parentVer) } def inspectDeps = { depsNode, String section -> depsNode.dependency.each { dep -> @@ -320,9 +365,18 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease org.zerojsample0.1.0 org.julclangjulc-stdlib0.1.0-pre21-SNAPSHOT ''' - def badBomPom = ''' + def badTimestampedPom = ''' + org.zerojsample0.1.0 + org.julclangjulc-stdlib0.1.0-20261120.174000-1 + ''' + def badBomPropPom = ''' org.zerojsample-bom0.1.0 - org.zerojzeroj-api0.1.0-SNAPSHOT + 0.1.0-SNAPSHOT + org.julclangjulc-stdlib${julc.ver} + ''' + def badUnresolvedPropPom = ''' + org.zerojsample-bom0.1.0 + org.julclangjulc-stdlib${missing.ver} ''' def badParentPom = ''' org.exampleparent1.0-SNAPSHOT @@ -330,17 +384,23 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease ''' def cleanPom = ''' org.zerojsample0.1.0-pre13 - org.julclangjulc-stdlib0.1.0-pre22 + 0.1.0-pre22 + + org.julclangjulc-stdlib${julc.ver} + org.examplenon-snapshot-qualifier1.0.0-snapshotter + ''' if (findSnapshotVersionsInPom(badDepPom, 'self-check').isEmpty() - || findSnapshotVersionsInPom(badBomPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badTimestampedPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badBomPropPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badUnresolvedPropPom, 'self-check').isEmpty() || findSnapshotVersionsInPom(badParentPom, 'self-check').isEmpty() || !findSnapshotVersionsInPom(cleanPom, 'self-check').isEmpty()) { throw new GradleException('Release -SNAPSHOT POM guard self-check failed.') } def rootVersion = rootProject.version.toString() - def isSnapshotBuild = rootVersion.toUpperCase(Locale.ROOT).endsWith('SNAPSHOT') + def isSnapshotBuild = isMavenSnapshot(rootVersion) if (isSnapshotBuild && !forceCheck) { logger.lifecycle("Skipping release -SNAPSHOT dependency guard for SNAPSHOT project version ${rootVersion}.") return @@ -354,6 +414,24 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease violations << "rootProject version is SNAPSHOT: ${rootVersion}" } + def scanConfiguration = { Configuration cfg, String label -> + if (cfg != null && cfg.canBeResolved) { + configCount++ + def result = cfg.incoming.resolutionResult + result.allDependencies.each { dep -> + if (dep instanceof org.gradle.api.artifacts.result.UnresolvedDependencyResult) { + violations << "${label}: unresolved dependency ${dep.requested} (${dep.failure.message})" + } + } + result.allComponents.each { comp -> + def mv = comp.moduleVersion + if (mv != null && isMavenSnapshot(mv.version)) { + violations << "${label}: ${mv.group}:${mv.name}:${mv.version}" + } + } + } + } + deployedProjects.each { candidate -> def pomTasks = candidate.tasks.withType(GenerateMavenPom).toList() if (pomTasks.isEmpty()) { @@ -372,49 +450,17 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease } ['compileClasspath', 'runtimeClasspath', 'annotationProcessor'].each { cfgName -> - def cfg = candidate.configurations.findByName(cfgName) - if (cfg != null && cfg.canBeResolved) { - configCount++ - def result = cfg.incoming.resolutionResult - result.allDependencies.each { dep -> - if (dep instanceof org.gradle.api.artifacts.result.UnresolvedDependencyResult) { - violations << "${candidate.path} [${cfgName}]: unresolved dependency ${dep.requested} (${dep.failure.message})" - } - } - result.allComponents.each { comp -> - def mv = comp.moduleVersion - if (mv != null && mv.version != null - && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { - violations << "${candidate.path} [${cfgName}]: ${mv.group}:${mv.name}:${mv.version}" - } - } - } - } - - def bsCfg = candidate.buildscript.configurations.findByName('classpath') - if (bsCfg != null && bsCfg.canBeResolved) { - configCount++ - bsCfg.incoming.resolutionResult.allComponents.each { comp -> - def mv = comp.moduleVersion - if (mv != null && mv.version != null - && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { - violations << "${candidate.path} [buildscript:classpath]: ${mv.group}:${mv.name}:${mv.version}" - } - } + scanConfiguration(candidate.configurations.findByName(cfgName), "${candidate.path} [${cfgName}]") } + // Note: covers buildscript { dependencies { classpath ... } } plugins (e.g. julc-gradle-plugin). + // Plugins resolved via settings pluginManagement / plugins {} blocks live on the settings + // classpath rather than project.buildscript and are pinned directly in plugin blocks. + scanConfiguration(candidate.buildscript.configurations.findByName('classpath'), + "${candidate.path} [buildscript:classpath]") } - def rootBsCfg = rootProject.buildscript.configurations.findByName('classpath') - if (rootBsCfg != null && rootBsCfg.canBeResolved) { - configCount++ - rootBsCfg.incoming.resolutionResult.allComponents.each { comp -> - def mv = comp.moduleVersion - if (mv != null && mv.version != null - && mv.version.toUpperCase(Locale.ROOT).contains('SNAPSHOT')) { - violations << ": [buildscript:classpath]: ${mv.group}:${mv.name}:${mv.version}" - } - } - } + scanConfiguration(rootProject.buildscript.configurations.findByName('classpath'), + ': [buildscript:classpath]') if (pomCount < deployedProjects.size()) { violations << "Scanned only ${pomCount} POMs across ${deployedProjects.size()} published projects" @@ -448,6 +494,11 @@ allprojects { candidate -> candidate.tasks.matching { it.name == 'publishAllPublicationsToStagingRepository' }.configureEach { dependsOn verifyNoSnapshotDeps } + candidate.tasks.withType(PublishToMavenRepository).configureEach { publishTask -> + if (publishTask.name.endsWith('ToStagingRepository') || publishTask.repository?.name == 'staging') { + publishTask.dependsOn verifyNoSnapshotDeps + } + } } // === ADR-0044 structural guard ================================================================= From 7d78aa4f8a65c19cc1dda05812cccaffdecd8232 Mon Sep 17 00:00:00 2001 From: Satya Date: Sat, 21 Nov 2026 01:50:25 +0800 Subject: [PATCH 3/3] Match Maven 3.9.9 case-insensitive SNAPSHOT suffix check and dev-mode skip convention --- build.gradle | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 6713e0da..a6b8a336 100644 --- a/build.gradle +++ b/build.gradle @@ -293,13 +293,15 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease doLast { // Matches org.apache.maven.artifact.ArtifactUtils.isSnapshot (Maven 3.9.9): - // literal "SNAPSHOT", suffix "-SNAPSHOT", or timestamped "-YYYYMMDD.HHMMSS-". + // case-insensitive terminal "SNAPSHOT" (with or without leading hyphen) or + // timestamped "-YYYYMMDD.HHMMSS-". + def snapSuffix = 'SNAPSHOT' def timestampedSnapshotPattern = ~/^(.*)-([0-9]{8}\.[0-9]{6})-([0-9]+)$/ def isMavenSnapshot = { String ver -> - if (ver == null || ver.isEmpty()) return false - return ver == 'SNAPSHOT' - || ver.endsWith('-SNAPSHOT') - || timestampedSnapshotPattern.matcher(ver).matches() + ver != null && !ver.isEmpty() && ( + (ver.length() >= snapSuffix.length() + && ver.regionMatches(true, ver.length() - snapSuffix.length(), snapSuffix, 0, snapSuffix.length())) + || timestampedSnapshotPattern.matcher(ver).matches()) } def resolvePomProperties = { String raw, Map props -> @@ -369,6 +371,14 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease org.zerojsample0.1.0 org.julclangjulc-stdlib0.1.0-20261120.174000-1 ''' + def badLowercaseSnapPom = ''' + org.zerojsample0.1.0 + org.julclangjulc-stdlib1.0-snapshot + ''' + def badNoHyphenSnapPom = ''' + org.zerojsample0.1.0 + org.julclangjulc-stdlib1.0SNAPSHOT + ''' def badBomPropPom = ''' org.zerojsample-bom0.1.0 0.1.0-SNAPSHOT @@ -392,6 +402,8 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease ''' if (findSnapshotVersionsInPom(badDepPom, 'self-check').isEmpty() || findSnapshotVersionsInPom(badTimestampedPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badLowercaseSnapPom, 'self-check').isEmpty() + || findSnapshotVersionsInPom(badNoHyphenSnapPom, 'self-check').isEmpty() || findSnapshotVersionsInPom(badBomPropPom, 'self-check').isEmpty() || findSnapshotVersionsInPom(badUnresolvedPropPom, 'self-check').isEmpty() || findSnapshotVersionsInPom(badParentPom, 'self-check').isEmpty() @@ -399,10 +411,14 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease throw new GradleException('Release -SNAPSHOT POM guard self-check failed.') } + // Only skip automatically for the build's own intentional development snapshot mode + // (`*-SNAPSHOT`, matching subprojects version rewriting and snapshot.yml). Any other + // Maven-snapshot version (e.g. lowercase `-snapshot` or timestamped) is treated as a + // release by the rest of the build and must therefore run and fail this guard. def rootVersion = rootProject.version.toString() - def isSnapshotBuild = isMavenSnapshot(rootVersion) - if (isSnapshotBuild && !forceCheck) { - logger.lifecycle("Skipping release -SNAPSHOT dependency guard for SNAPSHOT project version ${rootVersion}.") + def isDevSnapshotProject = rootVersion.endsWith('-SNAPSHOT') + if (isDevSnapshotProject && !forceCheck) { + logger.lifecycle("Skipping release -SNAPSHOT dependency guard for development SNAPSHOT version ${rootVersion}.") return } @@ -410,7 +426,7 @@ def verifyNoSnapshotDeps = tasks.register('verifyNoSnapshotDependenciesInRelease int pomCount = 0 int configCount = 0 - if (isSnapshotBuild) { + if (isMavenSnapshot(rootVersion)) { violations << "rootProject version is SNAPSHOT: ${rootVersion}" }