bazel icon indicating copy to clipboard operation
bazel copied to clipboard

It should be possible to attach a `rules_license` license to arbitrary targets

Open shs96c opened this issue 1 year ago • 7 comments

Description of the feature request:

Using package(default_package_metadata = []) it's possible to attach license information to every target in a build file, but in some cases it would be useful to add a specific license (or metadata) to a specific rule. The licenses attribute was previously used for this, but is now deprecated and only took a string

Which category does this issue belong to?

Core, External Dependency

What underlying problem are you trying to solve with this feature?

rules_jvm_external generates a single build file containing every third party dependency that a user can depend on. In order to integrate nicely with rules_license, it would be useful to be able to assign a specific license to each target, since each dependency may have its own license.

Which operating system are you running Bazel on?

n/a

What is the output of bazel info release?

n/a

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

shs96c avatar May 16 '24 13:05 shs96c

The presence of default_package_metadata in the package rule implies that there's a package_metadata attribute on rules. This doesn't appear to be the case with Bazel 7.1.0

shs96c avatar May 16 '24 16:05 shs96c

The presence of default_package_metadata in the package rule implies that there's a package_metadata attribute on rules. This doesn't appear to be the case with Bazel 7.1.0

just chatted to @aiuto -- he said that package_metadata is an implicit attribute on all rules. Probably undocumented though. Have you tried it?

Wyverald avatar May 16 '24 18:05 Wyverald

+1. This is a doc bug.

On Thu, May 16, 2024 at 2:13 PM Xùdōng Yáng @.***> wrote:

The presence of default_package_metadata in the package rule implies that there's a package_metadata attribute on rules. This doesn't appear to be the case with Bazel 7.1.0

just chatted to @aiuto https://github.com/aiuto -- he said that package_metadata is an implicit attribute on all rules. Probably undocumented though. Have you tried it?

— Reply to this email directly, view it on GitHub https://github.com/bazelbuild/bazel/issues/22403#issuecomment-2115902295, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXHHHHUVZ62OSA3DUXTSALZCTZNPAVCNFSM6AAAAABH2HPCOWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJVHEYDEMRZGU . You are receiving this because you were mentioned.Message ID: @.***>

aiuto avatar May 16 '24 18:05 aiuto

This attribute doesn't seem to be present in Bazel 7.1.1

shs96c avatar May 16 '24 19:05 shs96c

@aiuto It's not too late to cherry-pick this into 7.2.0.

fmeum avatar May 16 '24 19:05 fmeum

Huh? It should have been available months ago.

I'm OOO Friday (taking a bona-fide fun for me day), but I can try to find the history next week. If package_metadata is not on all rules, then applicable_licenses should be in all Bazel 7.x. The two are synonyms.

aiuto avatar May 16 '24 20:05 aiuto

applicable_licenses does appear to be present in 7.1.1. package_metadata appears to be absent.

shs96c avatar May 17 '24 10:05 shs96c

I sent https://github.com/bazelbuild/bazel/pull/22497 to encode the intended behavior in a test. Bazel 7 sets the applicable_licenses attribute, Bazel 8 will provide both to users while requiring rule authors to use package_metadata.

fmeum avatar May 22 '24 13:05 fmeum

Feel free to cherry pick this to 7.x, I'm going to close this one since it seems to be fixed at HEAD.

meteorcloudy avatar May 28 '24 15:05 meteorcloudy