Skip to content

Commit

Permalink
Omit unique module versions from canonical repo names
Browse files Browse the repository at this point in the history
The canonical repository name of a module `rules_foo` is now `rules_foo~` instead of e.g. `rules_foo~1.2.3` if there is only a single version of the module in the entire dep graph. This also applies to overrides, which previously used the canonical repository name `rules_foo~override`.

This improves cacheability of actions across module version changes and also prevents the output base from filling up with outdated module and extension repositories. See the long comment in `ModuleKey#getCanonicalRepoName` for a detailed explanation of why this particular scheme was chosen.

The change includes a bump of the lockfile version as the canonical repo names of label attributes in extension usages are affected.

RELNOTES: The scheme for generating canonical repository names has changed to improve cacheability of actions across dependency version updates. Note that canonical names are not considered to be public API and can change at any time. See https://bazel.build/external/module#repository_names_and_strict_deps for advice on how to avoid hardcoding canonical repository names.

Fixes #20997

Closes #21035.

PiperOrigin-RevId: 605730371
Change-Id: Ica1be1ba5493d3636248a79a6549a0927021bef9
  • Loading branch information
fmeum authored and Wyverald committed Feb 12, 2024
1 parent 72414c9 commit 3cf373b
Show file tree
Hide file tree
Showing 56 changed files with 671 additions and 954 deletions.
4 changes: 3 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ pkg_tar(
write_file(
name = "gen_maven_repo_name",
out = "MAVEN_CANONICAL_REPO_NAME",
content = [get_canonical_repo_name("@maven")],
# TODO: Use this instead after building with Bazel 7.1.0 or later.
# content = [get_canonical_repo_name("@maven")],
content = ["rules_jvm_external~~maven~maven"],
)

# The @maven repository is created by maven_install from rules_jvm_external.
Expand Down
Loading

0 comments on commit 3cf373b

Please sign in to comment.