Add variant compression to reduce generated Bazel targets for Android libraries#169
Closed
arunkumar9t2 wants to merge 4 commits intograb:masterfrom
Closed
Add variant compression to reduce generated Bazel targets for Android libraries#169arunkumar9t2 wants to merge 4 commits intograb:masterfrom
arunkumar9t2 wants to merge 4 commits intograb:masterfrom
Conversation
Implements intelligent grouping of equivalent Android build variants to reduce the number of generated Bazel targets.
Apply buildifier formatting: fix indentation and add trailing comma.
Changed bazel-build job to build only the demo-free-debug APK target instead of building all targets, reducing CI build time.
Reverted bazel-build to build all targets and bumped cache keys to invalidate existing caches.
Contributor
Author
|
The build is failing due to unrelated cache issue with crashlytics rules, will fix that separately |
minkuanlim-grabtaxi
approved these changes
Feb 2, 2026
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.
Summary
Implements variant compression to reduce Bazel targets generated from Android projects with multiple flavors/build types. Equivalent variants are collapsed into fewer targets.
Data Flow
flowchart TB subgraph Analysis["Phase 1: Analysis (runs first)"] Task[AnalyzeVariantCompressionTask] Sorter[TopologicalSorter] Extractor[AndroidLibraryDataExtractor] Compressor[VariantCompressor] Cache[(VariantCompressionService<br/>in-memory cache)] Task --> Sorter Sorter -->|ordered projects| Extractor Extractor -->|variant data| Compressor Compressor -->|compression result| Cache end subgraph Generation["Phase 2: Generation (runs after)"] GenTask[GenerateBazelScriptsTask] Builder[ProjectBazelFileBuilder] TargetBuilder[AndroidLibraryTargetBuilder] Cache2[(VariantCompressionService)] Output[BUILD.bazel] GenTask --> Builder Builder --> TargetBuilder Cache2 -->|pre-computed targets| TargetBuilder TargetBuilder --> Output end Cache -.->|shared service| Cache2How It Works
Phase 1 - Analysis:
AnalyzeVariantCompressionTaskruns firstVariantCompressionService(Gradle BuildService)Phase 2 - Generation:
GenerateBazelScriptsTaskruns per projectAndroidLibraryTargetBuilderqueries the cache:service.get(project.path)compressionResult.targetsinstead of re-extractingCompression Logic:
freeDebug≡paidDebug, emit single-debugtarget-debug≡-release, emit single target (no suffix)Key Files
AnalyzeVariantCompressionTask.ktVariantCompressionService.ktVariantCompressor.ktAndroidLibraryTargetBuilder.ktTasksManager.ktTopologicalSorter.kt