bazelbuild / rules_license

Apache License 2.0
80 stars 28 forks source link

Provide a user extensible compliance linter #92

Open aiuto opened 1 year ago

aiuto commented 1 year ago

Typically, every BUILD file in a bazel module is under the license defined at //:license. Since Bazel does not have inheritance from enclosing packages, we must usually add:

package(default_package_metadata=["//:license", "//:package_info"])

to every BUILD file. We should provide tools to help user maintain that invariant.

Initial thoughts:

@jin

fmeum commented 1 year ago

@Wyverald's REPO.bazel proposal may solve this.

jin commented 1 year ago

Android (AOSP) has a virtual monorepo structure like this:

% tree
.
├── external
│   ├── a
│   │   ├── BUILD
│   │   ├── LICENSE
│   │   ├── METADATA
│   │   └── sub
│   │       └── BUILD
│   └── b
│       ├── BUILD
│       ├── LICENSE
│       └── METADATA
└── foo
    └── BUILD

where //external/a and //external/b are git projects. They're also not necessarily repos like @a and @b, but //external/a and //external/b packages.

I think this shouldn't to be a bazel test. It could be like a buildifier-type standalone linter/static analyzer that fails loudly if some BUILD file doesn't have default_package_metadata set.