Reputation: 1322
When using Bazel in a multi repo environment what's the best strategy for maintaining dependency consistency?
Eg. Workspaces (individual git repos) A, B, C all depend on D. When the version of D changes, I want A, B and C to all be on the same version of D with the minimal amount of work.
Upvotes: 2
Views: 3322
Reputation: 2054
You can use git_repository
rule in A,B, and C's WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "D",
remote = "https://github.com/my_org/d",
branch = "master",
)
Notice that the branch
attribute is set to master
and not some specific commit. The branch doesn't have to be master. It could be any branch.
If you want a way to reproduce builds,
this can be done by using bazel sync
command.
There is a bazel blog post with detailed explanation of the steps you need to take to have a "snapshot" file of your external workspaces (resolved.bzl
).
You can use it either as another build artifact for future investigations or to have more control over when to update the "pointers" to the external workspace by calling bazel sync
with --experimental_repository_resolved_file=resolved.bzl
Upvotes: 2