Closed grimreaper closed 2 years ago
Can visibility
and package()
help?
Also package_group()
, which I've used to implement the type of "service can't depended on other services" type of visibility before.
package() can not help since it only applies to the given BUILD file.
package_group() is similar to what I was discussing here especially considering that it supports ...
in its definition. That said, it doesn't provide all the functionality I was discussing above. Even package
does not.
I'll close this ticket and open more specific feature requests though. I was unaware of package_group
prior.
Description of the problem / feature request:
Bazel lacks definition of a "metapackage"
Feature requests: what underlying problem are you trying to solve with this feature?
This is a bit of a meta ticket since it describes multiple problems and points out how they all stem from the same missing conceptual piece. A resolution to this ticket would be then both a solution for the conceptual piece and new tickets for each of the features.
A typical monorepo will have multiple services, libraries, scripts, or whatnot. For lack of a better term I will call these metapackage. A metapackage can thought of as a collection targets grouped under one directory. Users may wish to enforce rules at the component level.
Such rules include "services may not depend on one another", "libraries may not depend on services", "library A may not depend on library B", "all targets in service A must have fatal warnings enabled", "only a fixed set of targets can depend on deprecated library". In addition users may want to be able to query this conceptual piece, define properties or labels, and related pieces.
There is currently no way to define this inside of bazel. Any such implementation requires repeated and recursive calls to
bazel query
and utilities outside.For example imagine this code structure (with a BUILD file under each directory):
There is no way to define "yoda may not depend on harrypotter" or "set
fatal_warnings=True
on all targets under "yoda".