Public API for write_source_files

Macros and Functions


Write to one or more files in the source tree. Stamp out tests that ensure the files exists and are up to date.


load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")

    name = "write_foobar",
    files = {
        "foobar.json": "//some/generated:file",

To update the source file, run:

bazel run //:write_foobar

A test will fail if the source file doesn't exist

bazel test //...

//:foobar.json does not exist. To create & update this file, run:

    bazel run //:write_foobar

...or if it's out of date.

bazel test //...

//:foobar.json is out-of-date. To update this file, run:

    bazel run //:write_foobar


Name of the executable target that creates or updates the source file


A dict where the keys are source files to write to and the values are labels pointing to the desired content. Source files must be within the same bazel package as the target.


Other common named parameters such as tags or visibility