orshachar
orshachar

Reputation: 5037

bazel targets that are lazily built

I'm using "bazel-deps-like" solution to keep my maven third party jars. in a pair of maven_jar repository rule and java_import rule. As part of a big organisation I sync all of our managed dependencies to the workspace. That makes me having a lot more dependency targets that I actually use.

The problem is when running bazel build //... - it refers to all java_import (or scala_import) and downloads all jars (even those I don't need).

How can I tell bazel to build those third party targets only if referred in the other targets.

One very ugly solution I can think of is to move all internal targets to one main folder:

+ third_party
  | - com
  | - org
+ internal
  | - module-a
  | - module-b

and then I can build only my internal targets by running bazel run //internal/... But it's far from being elegant.

I'd be happy to have some kind of flag on targets that I don't want to be built unless directly or transitively required by targets that do not have this flag.

Upvotes: 0

Views: 414

Answers (1)

Jin
Jin

Reputation: 13533

Targets with tags=["manual"] will not be included in wildcard target patterns (..., :*, :all, etc). You should specify such test targets with explicit target patterns on the command line if you want Bazel to build/test them.

https://docs.bazel.build/versions/master/user-manual.html#target-patterns

Upvotes: 3

Related Questions