Bug 2071822 - Add gradle plugin to generate androidTest keep rules #395 (firefox-autoland@autoland)

Warnings
  • Checking...
Blockers
  • Checking...
Branches gradle-plugin-for-keep-rules -> autoland
Repo firefox-autoland@autoland (git) (git://github.com/pollym/firefox.git)
Author pollym
State closed
Commit Title

Bug 2071822 - Add gradle plugin to generate androidTest keep rules

Commit Body

R8 only sees the app during minification, so it removes or renames code that only the androidTest apk uses, and instrumented tests crash at runtime against a minified build. A hand-written rule set can't keep up, because the rules change whenever app or test code changes. This adds a new `android-test-keep-rules` gradle plugin. For the build type passed as `-PtestBuildType`, when that build type is minified, it runs R8's `TraceReferences` with the test apk as the source and the app as the target. It then adds the resulting keep rules to that variant's R8 config. Builds without `-PtestBuildType`, including all shipping builds, are unaffected. Fenix applies the plugin, and `proguard-rules-android-test.pro` adds `-dontwarn` rules for optional references in test-only libraries so R8 can process the test apk. The plugin has unit tests and a `source-test-android-gradle-plugins` ci job. CI test builds still pass `-PdisableOptimization`, so this changes nothing in ci until a minified ui test variant is added. [there is a green try here](https://treeherder.mozilla.org/jobs?repo=try&revision=e937c822474c688d0594a6f9ed026cf21ae08bc3) just to ensure that: - none of the usual fenix stuff is broken - the nightly ui tests still pass - the plugin's own unit tests pass - linters for the yml are happy [rerunning try here after last push to add docs](https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=107017) there is also a [google doc with the approach and implementation plan for this ticket here](https://docs.google.com/document/d/1BHoznUPqfRlQ7M5UbtgwTwSHbcQ9_PA9TKHCbSEiuFI/edit?tab=t.l5l9dq1u67wr)

Landings

Successfully landed

Landing requested on , by pmceldowney@mozilla.com.

Landing Job: 107068

Last update:

Result: 1a68818a733eb53991e4468e0837638c7730bab3 on firefox-autoland@autoland (git)

Links: Treeherder