Skip to content

Export the baseline profile an AAR ships from aar_import - #577

Open
MarcusChen-Canva wants to merge 1 commit into
bazelbuild:mainfrom
MarcusChen-Canva:baseline-profile-aar-import
Open

MarcusChen-Canva wants to merge 1 commit into
bazelbuild:mainfrom
MarcusChen-Canva:baseline-profile-aar-import

Conversation

@MarcusChen-Canva

Copy link
Copy Markdown

Fixes #461.

AARs built by the Android Gradle Plugin carry their baseline profile as baseline-prof.txt at the archive root; androidx activity, fragment, lifecycle-*, startup-runtime, the Compose artifacts and okhttp-android all ship one. The Gradle plugin merges every library's profile into the app's ART profile. aar_import extracted nothing, so an android_binary built from the same AARs shipped without those rules; only android_library's own baseline_profiles attribute reached BaselineProfileProvider.

This extracts the file with the existing extract_single_file helper (create_empty_file = True, so an AAR without a profile contributes an empty file) and exports it through BaselineProfileProvider, merged with the deps' and exports' profiles, the same shape android_library uses in rules/android_library/impl.bzl.

Verified in our monorepo on rules_android 0.7.3 (the same change rebased onto main here): the MergeBaselineProfiles action of our android_binary now receives the profiles of every AAR in its closure (25 of them carry rules) and produces a 3376-rule merged profile; before, nothing from an AAR reached it.

No test is added: test/rules has no aar_import coverage today, and the android_binary profile tests referenced from rules/acls are not in this repository. Happy to add one if you can point me at where an aar_import test with a checked-in AAR should live.

AARs built by the Android Gradle Plugin carry their baseline profile as
baseline-prof.txt at the archive root (androidx activity, fragment,
lifecycle, Compose and others do). The Gradle plugin merges every library's
profile into the app's ART profile; aar_import extracted nothing, so an
android_binary built from the same AARs shipped without those rules and
only android_library's own baseline_profiles attribute reached
BaselineProfileProvider.

Extract the file with the existing single-file extractor, falling back to
an empty file for AARs without one, and export it through
BaselineProfileProvider merged with the deps' and exports' profiles, the
same shape android_library uses.

Fixes bazelbuild#461

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@google-cla

google-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aar_import: baseline profile isn't exposed to the consumers

1 participant