Search code examples
bazelbazel-aspect

Running bazel build with an aspect on test targets does not yield test output jars


running bazel build //... \ --aspects some-aspect.bzl%some_aspect \ --output_groups=some_new_output,default does not create test jars outputs.

on the other hand running bazel test does create the test jar outputs:

bazel test //... \ --aspects some-aspect.bzl%some_aspect \ --output_groups=some_new_output,default

How come?

This question was updated to reflect use of aspects: The original question:

running bazel build //... does not add test code to output jar.

on the other hand bazel test //... builds the test code but also runs it.

Is there a way in bazel to build the test code without running the tests?


Solution

  • I had a mistake in the values I gave the --output_groups flag.

    It should have been --output_groups=+some_new_output,+default

    The default can even be omitted:

    --output_groups=+some_new_output

    This flag is not documented at all. There is an open issue on this in bazel github repo.