Export proguard specs from aar_import#12749
Closed
benjaminRomano wants to merge 1 commit intobazelbuild:masterfrom
Closed
Export proguard specs from aar_import#12749benjaminRomano wants to merge 1 commit intobazelbuild:masterfrom
benjaminRomano wants to merge 1 commit intobazelbuild:masterfrom
Conversation
Contributor
Author
|
I think the test failures are related to android_tools version need to be bumped? |
Contributor
|
Any updates on this? |
ahumesky
approved these changes
Feb 24, 2021
Contributor
|
Also, could you clarify what "the android rules would need to be bumped" means? If you're referring to the remote android tools (the dependencies automatically included by android_remote_tools.WORKSPACE), right now those don't contain these python tools. These python tools are still embedded within bazel. |
Contributor
Author
Contributor
|
Gotcha, so these python tools aren't part of the remote android tools. These get embedded in bazel. So these changes will be part of the next bazel release. |
katre
pushed a commit
that referenced
this pull request
Jul 12, 2021
**Background** #3778 proguard specs from the `aar_import` rule do not get bubbled up to `android_binary`. In this PR, I wire up a `ProguardSpecProvider` from this rule that exports the `proguard.txt` within an AAR if it exists and any transitive proguard specs from the `exports` attribute. **Changes** * Add an `aar_embedded_proguard_extractor` script to extract `proguard.txt` from an AAR if it exists otherwise generate an empty proguard specs file * In AarImport, wire up the proguard extractor action and export results through a `ProguardSpecProvider`. Once this lands, the android rules would need to be bumped. **Test Plan** * Added tests for the extraction python script * Added tests for the `aar_import` rule changes Closes #12749. PiperOrigin-RevId: 359667674
cpsauer
added a commit
to cpsauer/bazel
that referenced
this pull request
Mar 4, 2022
Background: JAR files can bundle ProGuard specs under `META-INF/proguard/` [See https://developer.android.com/studio/build/shrink-code] Problem: Bazel previously erroniously ignored these ProGuard specs, leading to failures with, for example, androidx.annotation.Keep. Bad times. There was previously a parallel issue with aar_import. [Fixed in bazelbuild#12749] Solution: This change causes the previously ignored, embedded proguards to be extracted, validated, and then bubbled up correctly via the ProguardSpecProvider. There's also a minor fix to aar_import, adding proguard validation and slightly simplifying the resulting code. For reasoning behind why library proguards should be validated, see the module docstring of proguard_whitelister.py Remaining issues: JAR files brought down from Maven via rules_jvm_external bypass java_import in favor of rolling their own jvm_import, since java_import apparently been broken for Kotlin for years. That'll need a subsequent fix, since this only fixes java_import. For context on the Kotlin breakage, see bazelbuild#4549. For the status on fixes in rules_jvm_external, see bazel-contrib/rules_jvm_external#672
cpsauer
added a commit
to cpsauer/bazel
that referenced
this pull request
Mar 5, 2022
Background: JAR files can bundle ProGuard specs under `META-INF/proguard/` [See https://developer.android.com/studio/build/shrink-code] Problem: Bazel previously erroniously ignored these ProGuard specs, leading to failures with, for example, androidx.annotation.Keep. Bad times. There was previously a parallel issue with aar_import. [Fixed in bazelbuild#12749] Solution: This change causes the previously ignored, embedded proguards to be extracted, validated, and then bubbled up correctly via the ProguardSpecProvider. There's also a minor fix to aar_import, adding proguard validation and slightly simplifying the resulting code. For reasoning behind why library proguards should be validated, see the module docstring of proguard_whitelister.py Remaining issues: JAR files brought down from Maven via rules_jvm_external bypass java_import in favor of rolling their own jvm_import, since java_import apparently been broken for Kotlin for years. That'll need a subsequent fix, since this only fixes java_import. For context on the Kotlin breakage, see bazelbuild#4549. For the status on fixes in rules_jvm_external, see bazel-contrib/rules_jvm_external#672
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
#3778
proguard specs from the
aar_importrule do not get bubbled up toandroid_binary. In this PR, I wire up aProguardSpecProviderfrom this rule that exports theproguard.txtwithin an AAR if it exists and any transitive proguard specs from theexportsattribute.Changes
aar_embedded_proguard_extractorscript to extractproguard.txtfrom an AAR if it exists otherwise generate an empty proguard specs fileProguardSpecProvider.Once this lands, the android rules would need to be bumped.
Test Plan
aar_importrule changes