57 lines
1.8 KiB
Markdown
57 lines
1.8 KiB
Markdown
# 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.
|
|
|
|
|
|
[Artifactory]: https://jfrog.com/artifactory/
|
|
[Aspect Build]: https://aspect.build/
|
|
[BCR]: https://registry.bazel.build/
|
|
[Cloudsmith]: https://cloudsmith.com/
|
|
[Engflow]: https://www.engflow.com/
|
|
[Nexus]: https://www.sonatype.com/products/sonatype-nexus-repository
|
|
|
|
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:
|
|
|
|
```bazelrc
|
|
# 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](https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/).
|
|
|
|
## 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_externally` flag,
|
|
which was on by default
|
|
- Bazel 9: behind the flag, which if off by default
|