Skip to content

Commit d95d82b

Browse files
committed
Added support for non-versioned snapshots
1 parent d049174 commit d95d82b

File tree

5 files changed

+1058
-7
lines changed

5 files changed

+1058
-7
lines changed

MODULE.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,10 @@ dev_maven.install(
757757
"androidx.annotation:annotation:1.6.0",
758758
# https://github.com/bazel-contrib/rules_jvm_external/issues/1409
759759
"com.squareup.okhttp3:okhttp:4.12.0",
760-
# Snapshot pinning support: https://github.com/bazel-contrib/rules_jvm_external/pull/1412
760+
# Versioned snapshot pinning support: https://github.com/bazel-contrib/rules_jvm_external/pull/1412
761761
"com.google.guava:guava:999.0.0-HEAD-jre-SNAPSHOT",
762+
# Non-versioned snapshot pinning support: https://github.com/bazel-contrib/rules_jvm_external/pull/1412
763+
"org.seleniumhq.selenium:selenium-java:4.34.0-SNAPSHOT",
762764
],
763765
generate_compat_repositories = True,
764766
lock_file = "//tests/custom_maven_install:regression_testing_gradle_install.json",

private/extensions/download_pinned_deps.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def download_pinned_deps(mctx, artifacts, http_files, has_m2local):
3737

3838
http_file(
3939
name = http_file_repository_name,
40-
sha256 = artifact["sha256"],
40+
# sha256 is optional: non-versioned snapshots may not have it
41+
# See: https://github.com/bazel-contrib/rules_jvm_external/pull/1412
42+
sha256 = artifact.get("sha256"),
4143
urls = urls,
4244
# https://github.com/bazelbuild/rules_jvm_external/issues/1028
4345
downloaded_file_path = "v1/%s" % artifact["file"] if artifact["file"] else artifact["file"],

private/rules/coursier.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ def _pinned_coursier_fetch_impl(repository_ctx):
597597
http_files.extend([
598598
" http_file(",
599599
" name = \"%s\"," % http_file_repository_name,
600-
" sha256 = \"%s\"," % artifact["sha256"],
600+
# sha256 is optional: non-versioned snapshots may not have it
601+
# See: https://github.com/bazel-contrib/rules_jvm_external/pull/1412
602+
" sha256 = \"%s\"," % artifact.get("sha256", None),
601603
# repository_ctx should point to external/$repository_ctx.name
602604
# The http_file should point to external/$http_file_repository_name
603605
# File-path is relative defined from http_file traveling to repository_ctx.

private/tools/java/com/github/bazelbuild/rules_jvm_external/resolver/lockfile/V2LockFile.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,15 @@ public Map<String, Object> render() {
231231
@SuppressWarnings("unchecked")
232232
Map<String, String> shasums =
233233
(Map<String, String>) artifactValue.computeIfAbsent("shasums", k -> new TreeMap<>());
234-
info.getSha256().ifPresent(sha -> shasums.put(classifier, sha));
234+
235+
// For non-versioned snapshots, their content can change any moment, so we need to avoid storing the SHA256
236+
boolean isNonVersionedSnapshot = coords.getVersion().endsWith("-SNAPSHOT") && coords.getVersionRevision() == null;
237+
if (isNonVersionedSnapshot) {
238+
// Classifier indicates the files associated to the dependency: store it even if the sha is not present
239+
shasums.put(classifier, null);
240+
} else {
241+
info.getSha256().ifPresent(sha -> shasums.put(classifier, sha));
242+
}
235243

236244
info.getRepositories()
237245
.forEach(

0 commit comments

Comments
 (0)