Skip to content

Commit

Permalink
Add AndroidManifest.xml to android_aar
Browse files Browse the repository at this point in the history
Summary: Use the function we already have for building an Android Manifest, and stick that into the `.aar`.

Reviewed By: navidqar

Differential Revision: D48194650

fbshipit-source-id: aedd9728a3e5812c52c595059036e5bd0d99b5bc
  • Loading branch information
Ian Childs authored and facebook-github-bot committed Aug 10, 2023
1 parent 35b3fad commit cf90705
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion prelude/android/android_aar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.

load("@prelude//android:android_binary_resources_rules.bzl", "get_manifest")
load("@prelude//android:android_providers.bzl", "merge_android_packageable_info")
load("@prelude//java:java_providers.bzl", "get_all_java_packaging_deps")
load("@prelude//java:java_toolchain.bzl", "JavaToolchainInfo")
load("@prelude//utils:utils.bzl", "flatten")
Expand All @@ -14,6 +16,9 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
deps = ctx.attrs.deps

java_packaging_deps = [packaging_dep for packaging_dep in get_all_java_packaging_deps(ctx, deps)]
android_packageable_info = merge_android_packageable_info(ctx.label, ctx.actions, deps)

android_manifest = get_manifest(ctx, android_packageable_info, manifest_entries = {})

jars = [dep.jar for dep in java_packaging_deps if dep.jar]
classes_jar = ctx.actions.declare_output("classes.jar")
Expand All @@ -31,7 +36,7 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
zip_file_toolchain = ctx.attrs._zip_file_toolchain[ZipFileToolchainInfo]
create_zip_tool = zip_file_toolchain.create_zip

entries = [classes_jar]
entries = [android_manifest, classes_jar]
entries_file = ctx.actions.write("entries.txt", flatten([[entry, "ignored_short_path", "false"] for entry in entries]))

aar = ctx.actions.declare_output("{}.aar".format(ctx.label.name))
Expand Down
4 changes: 2 additions & 2 deletions prelude/android/android_binary_resources_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_android_binary_resources_info(
android_toolchain,
)

android_manifest = _get_manifest(ctx, android_packageable_info, manifest_entries)
android_manifest = get_manifest(ctx, android_packageable_info, manifest_entries)

non_proto_format_aapt2_link_info, proto_format_aapt2_link_info = get_aapt2_link(
ctx,
Expand Down Expand Up @@ -409,7 +409,7 @@ def _maybe_package_strings_as_assets(

return string_assets_zip

def _get_manifest(
def get_manifest(
ctx: AnalysisContext,
android_packageable_info: AndroidPackageableInfo.type,
manifest_entries: dict) -> Artifact:
Expand Down

0 comments on commit cf90705

Please sign in to comment.