Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support propagate_transitive_resources_class_jars #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions rules/android_library/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def _process_resources(ctx, java_package, manifest_ctx, **unused_ctxs):
# misbehavior on the Java side.
fix_resource_transitivity = bool(ctx.attr.srcs),
fix_export_exporting = acls.in_fix_export_exporting_rollout(str(ctx.label)),
propagate_transitive_resources_class_jars = _flags.get(ctx).propagate_transitive_resources_class_jars,

# Tool and Processing related inputs
aapt = get_android_toolchain(ctx).aapt2.files_to_run,
Expand Down
6 changes: 6 additions & 0 deletions rules/flags/flag_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ def define_flags():
default = True,
description = "Use Studio Deployer to install apks",
)

flags.DEFINE_bool(
name = "propagate_transitive_resources_class_jars",
default = True,
description = "Collect and propagate transitive resources class jars from dependencies",
)
10 changes: 7 additions & 3 deletions rules/resources.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ def _process_starlark(
neverlink = False,
enable_data_binding = False,
propagate_resources = True,
propagate_transitive_resources_class_jars = True,
fix_resource_transitivity = False,
aapt = None,
android_jar = None,
Expand Down Expand Up @@ -1230,6 +1231,9 @@ def _process_starlark(
propagate_resources: boolean. If false, the target will no longer propagate
providers required for Android Resource processing/packaging. But will
continue to propagate others (AndroidLibraryResourceClassJarProvider).
propagate_transitive_resources_class_jars: boolean. If false, the target will no longer propagate
the transitive Android Resource class jars as part of the AndroidLibraryResourceClassJarProvider
provider and will only propagate the direct Android Resource class jar.
fix_resource_transitivity: Whether to ensure that transitive resources are
correctly marked as transitive.
aapt: FilesToRunProvider. The aapt executable or FilesToRunProvider.
Expand Down Expand Up @@ -1789,15 +1793,14 @@ def _process_starlark(
deps,
exports,
)
],
] if propagate_transitive_resources_class_jars else [],
order = "preorder",
),
),
)

return resources_ctx


def _process(
ctx,
manifest = None,
Expand Down Expand Up @@ -1828,6 +1831,7 @@ def _process(
fix_resource_transitivity = False,
fix_export_exporting = False,
propagate_resources = True,
propagate_transitive_resources_class_jars = True,
zip_tool = None):
out_ctx = _process_starlark(
ctx,
Expand All @@ -1851,6 +1855,7 @@ def _process(
fix_resource_transitivity = fix_resource_transitivity,
neverlink = neverlink,
propagate_resources = propagate_resources,
propagate_transitive_resources_class_jars = propagate_transitive_resources_class_jars,
android_jar = android_jar,
aapt = aapt,
android_kit = android_kit,
Expand All @@ -1862,7 +1867,6 @@ def _process(
zip_tool = zip_tool,
)


if _VALIDATION_OUTPUTS not in out_ctx:
out_ctx[_VALIDATION_OUTPUTS] = []

Expand Down