I want a Bazel rule that is able to build multiple targets at once. So basically something like this:
build_all(
name = "build_all",
targets = [
"//services/service1:build",
"//services/service2:build",
"//services/service3:build",
]
)
So I would just run
bazel build //:build_all
to build all my services with one simple command (and the same for testing). But I couldn't find any current solutions.
Is there a way to achieve this?
It would appear that filegroup
would be a ready made rule that could be abused for the purpose:
filegroup(
name = "build_all",
srcs = [
"//services/service1:build",
"//services/service2:build",
"//services/service3:build",
]
)
It otherwise allows you to give a collective name to bunch of files (labels) to be passed conveniently along, but seems to work just as well as a summary target to use on the command line.
Because I was trying to deploy multiple Kubernetes configurations I ended up using Multi-Object Actions for rules_k8s which then looks like:
load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")
k8s_objects(
name = "deployments",
objects = [
"//services/service1:build",
"//services/service2:build",
"//services/service3:build",
]
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With