Skip to content

test(jvm): R8/ProGuard DCE verification for plain JVM/Desktop builds #212

Description

@kirich1409

Goal

Verify that the same -assumevalues ProGuard rules generated by featured-gradle-plugin strip disabled-flag branches from a plain JVM/Desktop application processed by R8 or ProGuard — not only Android APKs.

Context

Today featured-shrinker-tests exercises R8 against synthetic bytecode shaped like an Android app. The Featured plugin also wires JVM and Desktop targets through core and featured-compose; consumers want the same DCE guarantee for desktop apps such as :sample:desktop.

The single existing JVM-shaped consumer of these rules is proguard-rules.pro aggregation, but no test proves the rules apply outside the AGP variant context.

Approach

  • Build a small JVM jar that calls a generated is*Enabled() extension and references both branches.
  • Apply the generated proguard-featured.pro via R8 library mode (or ProGuard CLI).
  • Inspect the optimized jar and assert the disabled branch's class/method is absent.
  • Cover Boolean and Int flags at minimum.

References

  • Plugin generator: build-logic/featured-gradle-plugin/src/main/kotlin/dev/androidbroadcast/featured/gradle/ProguardRulesGenerator.kt
  • Extension generator (for the call site class name): build-logic/featured-gradle-plugin/src/main/kotlin/dev/androidbroadcast/featured/gradle/ExtensionFunctionGenerator.kt
  • Existing Android reference test: featured-shrinker-tests/src/test/kotlin/dev/androidbroadcast/featured/shrinker/R8BooleanFlagEliminationTest.kt

Definition of Done

  • New scenario(s) in featured-shrinker-tests exercise plain-JVM bytecode (no Android Manifest in the test fixture)
  • Boolean and Int flag stripping verified
  • Wiki page Release Optimization documents JVM/Desktop usage with a link to the test
  • CHANGELOG.md [Unreleased] entry

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    gradle-pluginfeatured-gradle-plugin worktestingTests and coverage

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions