Skip to content

Commit efccc13

Browse files
timpeutcopybara-github
authored andcommitted
Create and wire up an ACL to enable android_library to export aar_import lint checks.
PiperOrigin-RevId: 789941748 Change-Id: I501c1317dff6a0f07fbb2edda93c276d9c08f546
1 parent c604844 commit efccc13

3 files changed

Lines changed: 37 additions & 11 deletions

File tree

rules/acls.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ load("//rules/acls:databinding.bzl", "DATABINDING_ALLOWED", "DATABINDING_DISALLO
5959
load("//rules/acls:desugaring_runtime_jar_classpath.bzl", "DESUGAR_USE_RUNTIME_JARS")
6060
load("//rules/acls:dex2oat_opts.bzl", "CAN_USE_DEX2OAT_OPTIONS")
6161
load("//rules/acls:disable_optimizing_dexer.bzl", "DISABLE_OPTIMIZING_DEXER")
62+
load("//rules/acls:enable_exported_lint_checks.bzl", "ENABLE_EXPORTED_LINT_CHECKS")
6263
load("//rules/acls:force_final_resources.bzl", "FORCE_FINAL_ANDROID_BINARY_RESOURCES")
6364
load("//rules/acls:install_apps_in_data.bzl", "INSTALL_APPS_IN_DATA")
6465
load("//rules/acls:lint_registry_rollout.bzl", "LINT_REGISTRY_FALLBACK", "LINT_REGISTRY_ROLLOUT")
@@ -215,6 +216,9 @@ def _in_resource_translation_merging_rollout(fqn):
215216
def _in_d8_optimization_metadata(fqn):
216217
return matches(fqn, D8_OPTIMIZATION_METADATA_DICT)
217218

219+
def _in_enable_exported_lint_checks(fqn):
220+
return matches(fqn, ENABLE_EXPORTED_LINT_CHECKS_DICT)
221+
218222
def make_dict(lst):
219223
"""Do not use this method outside of acls directory."""
220224
return {t: True for t in lst}
@@ -283,6 +287,7 @@ STAMP_SIGNING_ROLLOUT_DICT = make_dict(STAMP_SIGNING_ROLLOUT)
283287
STAMP_SIGNING_FALLBACK_DICT = make_dict(STAMP_SIGNING_FALLBACK)
284288
RESOURCE_TRANSLATION_MERGING_ROLLOUT_DICT = make_dict(RESOURCE_TRANSLATION_MERGING_ROLLOUT)
285289
RESOURCE_TRANSLATION_MERGING_FALLBACK_DICT = make_dict(RESOURCE_TRANSLATION_MERGING_FALLBACK)
290+
ENABLE_EXPORTED_LINT_CHECKS_DICT = make_dict(ENABLE_EXPORTED_LINT_CHECKS)
286291

287292
def matches(fqn, dct):
288293
# Labels with workspace names ("@workspace//pkg:target") are not supported.
@@ -379,6 +384,7 @@ acls = struct(
379384
in_stamp_signing_rollout = _in_stamp_signing_rollout,
380385
in_desugaring_runtime_jar_classpath_rollout = _in_desugaring_runtime_jar_classpath_rollout,
381386
in_resource_translation_merging_rollout = _in_resource_translation_merging_rollout,
387+
in_enable_exported_lint_checks = _in_enable_exported_lint_checks,
382388
)
383389

384390
# Visible for testing
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Temporary allowlist to enable exported lint checks."""
16+
17+
ENABLE_EXPORTED_LINT_CHECKS = [
18+
"//:__subpackages__",
19+
]

rules/android_library/impl.bzl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,19 @@ def _process_jvm(ctx, exceptions_ctx, resources_ctx, idl_ctx, db_ctx, **unused_s
306306
)
307307

308308
def _process_lint_rules(ctx, **unused_sub_ctxs):
309-
# Propagate Lint rule Jars from any exported AARs (b/229993446)
310-
android_lint_rules = [info.lint_jars for info in utils.collect_providers(
311-
AndroidLintRulesInfo,
312-
ctx.attr.exports,
313-
)]
314309
providers = []
315-
if android_lint_rules:
316-
providers.append(
317-
AndroidLintRulesInfo(
318-
lint_jars = depset(transitive = android_lint_rules),
319-
),
320-
)
310+
if acls.in_enable_exported_lint_checks(str(ctx.label)):
311+
# Propagate Lint rule Jars from any exported AARs (b/229993446)
312+
android_lint_rules = [info.lint_jars for info in utils.collect_providers(
313+
AndroidLintRulesInfo,
314+
ctx.attr.exports,
315+
)]
316+
if android_lint_rules:
317+
providers.append(
318+
AndroidLintRulesInfo(
319+
lint_jars = depset(transitive = android_lint_rules),
320+
),
321+
)
321322
return ProviderInfo(
322323
name = "lint_rules_ctx",
323324
value = struct(

0 commit comments

Comments
 (0)