diff options
author | Tony Aiuto <aiuto@google.com> | 2022-08-02 14:49:25 -0400 |
---|---|---|
committer | Tony Aiuto <aiuto@google.com> | 2022-08-02 14:49:25 -0400 |
commit | 5af7c6b51204145bda26632dd84aca97898b42f7 (patch) | |
tree | 50b134314544aab51712f07a6af9cc97313f56db /rules/gather_licenses_info.bzl | |
parent | 880c4fb5257791cde9ad27549eb39435e7faf8dc (diff) | |
download | bazelbuild-rules_license-5af7c6b51204145bda26632dd84aca97898b42f7.tar.gz |
put the package version in the short copyright list demo
Diffstat (limited to 'rules/gather_licenses_info.bzl')
-rw-r--r-- | rules/gather_licenses_info.bzl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/rules/gather_licenses_info.bzl b/rules/gather_licenses_info.bzl index 1b95b45..bd8c210 100644 --- a/rules/gather_licenses_info.bzl +++ b/rules/gather_licenses_info.bzl @@ -57,6 +57,11 @@ gather_licenses_info = aspect( apply_to_generating_rules = True, ) +def _quotes_or_null(s): + if not s: + return "null" + return '"%s"' % s + def write_licenses_info(ctx, deps, json_out): """Writes LicensesInfo providers for a set of targets as JSON. @@ -93,8 +98,8 @@ def write_licenses_info(ctx, deps, json_out): ], "copyright_notice": "{copyright_notice}", "package_name": "{package_name}", - "package_url": "{package_url}", - "package_version": "{package_version}", + "package_url": {package_url}, + "package_version": {package_version}, "license_text": "{license_text}"\n }}""" kind_template = """ @@ -120,8 +125,8 @@ def write_licenses_info(ctx, deps, json_out): rule = license.rule, copyright_notice = license.copyright_notice, package_name = license.package_name, - package_url = license.package_url or "<unknown>", - package_version = license.package_version or "<unknown>", + package_url = _quotes_or_null(license.package_url), + package_version = _quotes_or_null(license.package_version), license_text = license.license_text.path, kinds = ",\n".join(kinds), )) |