From 6c1b2ef1df8753463a3f99b382ffce0beaed0e8d Mon Sep 17 00:00:00 2001 From: Wei Li Date: Fri, 5 May 2023 10:56:51 -0700 Subject: Check LicenseInfo provider since there might be more metadata included in attribute "applicable_licenses". Ignore default_metadata_file targets in apex_deps_aspect. Bug: 275472038 Test: CIs (cherry picked from https://android-review.googlesource.com/q/commit:0cb9f8fccce40c5dfc0b05107361ad04f77fc874) Merged-In: I98d3f9bb0235b082a7db64e3f2ad790e4d9c3d15 Change-Id: I98d3f9bb0235b082a7db64e3f2ad790e4d9c3d15 --- rules/apex/apex_deps_validation.bzl | 6 +++++- rules/license/license_aspect.bzl | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rules/apex/apex_deps_validation.bzl b/rules/apex/apex_deps_validation.bzl index 4d5e39de..f69b30e3 100644 --- a/rules/apex/apex_deps_validation.bzl +++ b/rules/apex/apex_deps_validation.bzl @@ -75,6 +75,9 @@ _IGNORED_ATTRS = [ "androidmk_dynamic_deps", "androidmk_deps", ] +_IGNORED_TARGETS = [ + "default_metadata_file", +] def _should_skip_apex_dep(target, ctx): # Ignore Bazel-specific targets like platform/os/arch constraints, @@ -85,7 +88,8 @@ def _should_skip_apex_dep(target, ctx): ctx.label.workspace_name in _IGNORED_REPOSITORIES or ctx.label.package in _IGNORED_PACKAGES or ctx.rule.kind in _IGNORED_RULE_KINDS or - True in [p in target for p in _IGNORED_PROVIDERS] + True in [p in target for p in _IGNORED_PROVIDERS] or + target.label.name in _IGNORED_TARGETS ) def _apex_dep_validation_aspect_impl(target, ctx): diff --git a/rules/license/license_aspect.bzl b/rules/license/license_aspect.bzl index 1b6d27d5..2302137b 100644 --- a/rules/license/license_aspect.bzl +++ b/rules/license/license_aspect.bzl @@ -87,6 +87,8 @@ def license_map(deps): license_by_label = dict() licensees = dict() for lic in depset(transitive = transitive_licenses).to_list(): + if not LicenseInfo in lic: + continue label = lic[LicenseInfo].label.name if not label in license_by_label: license_by_label[label] = lic -- cgit v1.2.3