1.8 KiB
Module
Declarations in that file allow referencing external dependenciess
It completely replaces the legacy WORKSPACE file.
Registries
Dependencies are not resolved through registries, with the Bazel Central Registry (BCR) as the default.
Modules can be mirrored locally in a company registry, or proxied through an artifact server.
- Artifactory and Cloudsmith
- provides local hosting
- provides proxying for https://bcr.bazel.build
- Aspect Build and EngFlow : includes these features in their remote execution offering
- Nexus is sometimes used to serve raw repositores
For local packages, any HTTP static files server can be used: a bazel registry is just a collection of files in a specific layout.
Adding a registry to a MODULE.bazel file:
# Prioritize your internal registry, then fallback to BCR
common --registry=https://bazel-registry.internal.corp
common --registry=https://bcr.bazel.build
Since Bazel 9, if the BCR website goes down, you can bypass it entirely by pointing the --registry flag directly to its raw
GitHub URL.
Locking
The bzlmod resolver computes a modules graph, applies version selection rules, and creates a lockfile.
The lockfile pins the exact versions of all dependencies, to enable reproducible builds.
Upgrading
Default built-in rules like rules_java were
- Bazel 7: "built-in" and a default in 7
- Bazel 8: behind the
--incompatible_autoload_externallyflag, which was on by default - Bazel 9: behind the flag, which if off by default