Skip to content

Commit 1b3343d

Browse files
committed
Support propagate_transitive_resources_class_jars
1 parent 587baec commit 1b3343d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

rules/android_library/impl.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def _process_resources(ctx, java_package, manifest_ctx, **unused_ctxs):
176176
# misbehavior on the Java side.
177177
fix_resource_transitivity = bool(ctx.attr.srcs),
178178
fix_export_exporting = acls.in_fix_export_exporting_rollout(str(ctx.label)),
179+
propagate_transitive_resources_class_jars = _flags.get(ctx).propagate_transitive_resources_class_jars,
179180

180181
# Tool and Processing related inputs
181182
aapt = get_android_toolchain(ctx).aapt2.files_to_run,

rules/flags/flag_defs.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,9 @@ def define_flags():
9797
default = True,
9898
description = "Use Studio Deployer to install apks",
9999
)
100+
101+
flags.DEFINE_bool(
102+
name = "propagate_transitive_resources_class_jars",
103+
default = True,
104+
description = "Collect and propagate transitive resources class jars from dependencies",
105+
)

rules/resources.bzl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ def _process_starlark(
11801180
neverlink = False,
11811181
enable_data_binding = False,
11821182
propagate_resources = True,
1183+
propagate_transitive_resources_class_jars = True,
11831184
fix_resource_transitivity = False,
11841185
aapt = None,
11851186
android_jar = None,
@@ -1230,6 +1231,9 @@ def _process_starlark(
12301231
propagate_resources: boolean. If false, the target will no longer propagate
12311232
providers required for Android Resource processing/packaging. But will
12321233
continue to propagate others (AndroidLibraryResourceClassJarProvider).
1234+
propagate_transitive_resources_class_jars: boolean. If false, the target will no longer propagate
1235+
the transitive Android Resource class jars as part of the AndroidLibraryResourceClassJarProvider
1236+
provider and will only propagate the direct Android Resource class jar.
12331237
fix_resource_transitivity: Whether to ensure that transitive resources are
12341238
correctly marked as transitive.
12351239
aapt: FilesToRunProvider. The aapt executable or FilesToRunProvider.
@@ -1789,15 +1793,14 @@ def _process_starlark(
17891793
deps,
17901794
exports,
17911795
)
1792-
],
1796+
] if propagate_transitive_resources_class_jars else [],
17931797
order = "preorder",
17941798
),
17951799
),
17961800
)
17971801

17981802
return resources_ctx
17991803

1800-
18011804
def _process(
18021805
ctx,
18031806
manifest = None,
@@ -1828,6 +1831,7 @@ def _process(
18281831
fix_resource_transitivity = False,
18291832
fix_export_exporting = False,
18301833
propagate_resources = True,
1834+
propagate_transitive_resources_class_jars = True,
18311835
zip_tool = None):
18321836
out_ctx = _process_starlark(
18331837
ctx,
@@ -1851,6 +1855,7 @@ def _process(
18511855
fix_resource_transitivity = fix_resource_transitivity,
18521856
neverlink = neverlink,
18531857
propagate_resources = propagate_resources,
1858+
propagate_transitive_resources_class_jars = propagate_transitive_resources_class_jars,
18541859
android_jar = android_jar,
18551860
aapt = aapt,
18561861
android_kit = android_kit,
@@ -1862,7 +1867,6 @@ def _process(
18621867
zip_tool = zip_tool,
18631868
)
18641869

1865-
18661870
if _VALIDATION_OUTPUTS not in out_ctx:
18671871
out_ctx[_VALIDATION_OUTPUTS] = []
18681872

0 commit comments

Comments
 (0)