To use Dagger in a Bazel project, follow these steps:
- Import the Dagger repository: Add an
http_archive rule to your top-level WORKSPACE file pointing to a tagged release. - Load artifacts: Use
DAGGER_ARTIFACTS and DAGGER_REPOSITORIES from @dagger//:workspace_defs.bzl within your maven_install configuration. - Setup build rules: Call
dagger_rules() in your top-level BUILD file to expose the necessary Dagger targets.
# Top-level WORKSPACE file
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
DAGGER_TAG = "2.60.1"
DAGGER_SHA = "7ecce51ca45c551182df10fe4ea48fcdaabacaa282832a4244c04934e87fbc47"
http_archive(
name = "dagger",
strip_prefix = "dagger-dagger-%s" % DAGGER_TAG,
sha256 = DAGGER_SHA,
urls = ["https://github.com/google/dagger/archive/dagger-%s.zip" % DAGGER_TAG],
)
load("@dagger//:workspace_defs.bzl", "DAGGER_ARTIFACTS", "DAGGER_REPOSITORIES")
maven_install(
artifacts = DAGGER_ARTIFACTS + [...],
repositories = DAGGER_REPOSITORIES + [...],
)
# Top-level BUILD file
load("@dagger//:workspace_defs.bzl", "dagger_rules")
dagger_rules()