-
-
Notifications
You must be signed in to change notification settings - Fork 23
Description
When running stabilityCheck or stabilityDump tasks in a multi-variant Android project, the plugin compiles all build variants (including all product flavors and build types) instead of allowing users to analyze a single variant.
Current Behavior
For a project with 3 product flavors (prod, prodReplica, staging) and 2 build types (debug, release), running:
./gradlew stabilityDump
Triggers compilation of all 6 variants:
compileProdDebugKotlin
compileProdReleaseKotlin
compileProdReplicaDebugKotlin
compileProdReplicaReleaseKotlin
compileStagingDebugKotlin
compileStagingReleaseKotlin
This significantly increases build time, especially in large multi-module projects.
Expected Behavior
Users should be able to run stability analysis on a single variant to reduce build time. Ideally:
Variant-specific tasks: Similar to how Android creates tasks like assembleProdDebug, there should be variant-specific stability tasks like:
stabilityProdDebugDump
stabilityProdDebugCheck
etc.
Configuration option: Allow users to specify which variant(s) to analyze:
composeStabilityAnalyzer {
stabilityValidation {
targetVariants.set(listOf("prodDebug")) // Only analyze this variant
}
}
Default to a specific variant: Similar to how Android Studio defaults to a specific build variant, the plugin could default to analyzing only the currently selected variant or the default variant.
Workaround Attempted
I tried overriding task dependencies in the root build.gradle.kts:
afterEvaluate {
tasks.named("stabilityDump").configure {
setDependsOn(emptyList<Any>())
dependsOn("compileProdDebugKotlin")
}
}
However, the Kotlin compiler plugin is still applied to all variants during compilation, so other variants still get compiled.
Suggested Solution
Modify the plugin to create variant-specific stability tasks, similar to how the Android Gradle Plugin creates variant-specific tasks for assemble, bundle, etc. This would:
- Allow users to analyze specific variants
- Reduce build times significantly for large projects
- Align with Android build conventions