Repository navigation
feat(flutter_tools): extract AndroidGradleConfig and move toGradleConfig to AndroidBuildInfo - #194016
Conversation
…fig to AndroidBuildInfo - Introduce AndroidGradleConfig in build_info.dart and replace the 6 loose android* parameters on BuildInfo and BuildInfo.copyWith with androidGradleConfig. - Move toGradleConfig() off BuildInfo onto AndroidBuildInfo (with zero @deprecated forwarders) and add gradleDaemon / skipBuildDependencyValidation getters on AndroidBuildInfo. - Update FlutterCommand.getBuildInfo() and gradle.dart callers to use AndroidGradleConfig and AndroidBuildInfo.toGradleConfig(). - Update unit tests across build_info_test.dart, flutter_command_test.dart, android_gradle_builder_test.dart, and build_aar_test.dart.
There was a problem hiding this comment.
Code Review
This pull request refactors BuildInfo by grouping Android and Gradle-specific configurations into a new AndroidGradleConfig class, updating the corresponding references and tests. Feedback suggests updating the copyWith method in BuildInfo to allow overriding the new androidGradleConfig field.
reidbaker
left a comment
There was a problem hiding this comment.
What problem does this pr solve for what type of user?
is this a code organization optimization for maintainers only or is there some other use case I dont see?
It's 100% code maintenance. This aligns the definition of the arg (including the TYPE of arg) with the usage. So we end up with MUCH more maintainable code. Makes adding arg +1 MUCH easier because args are now self describing so we don't end up with drift RE: is this optional? Is this an enum value or a string? etc etc |
|
See previous PRs @reidbaker |
|
Cool this will get a review next week with a focus on who might get broken by this change. |
|
@bkonyi has reviewed previous ones here. He's fully "read in" to my goals here! |
- Remove `gradleDaemon` and `skipBuildDependencyValidation` forwarding getters from `AndroidBuildInfo` and read `buildInfo.androidGradleConfig` directly in `gradle.dart`. - Move `-Psplit-per-abi=true` into `AndroidBuildInfo.toGradleConfig()` and clarify `targetArchs` (`-Ptarget-platform`) in its Dartdoc. - Add `DummyAllBuildOptionsFlutterCommand` CLI parsing test for `AndroidGradleConfig` options in `flutter_command_test.dart`. - Clean up test description and comment in `android_gradle_builder_test.dart`.
Addressed in e832053 (removed AndroidBuildInfo forwarding getters, moved -Psplit-per-abi=true into toGradleConfig(), and added CLI option parsing test); re-requesting review from @reidbaker.
Roll Flutter from 4249ccbc18a3 to 426be968b5eb (44 revisions) flutter/flutter@4249ccb...426be96 2026-10-14 [email protected] Allow color delta tolerance in in-memory fuzzy image comparator (flutter/flutter#193937) 2026-10-14 [email protected] [web] Drop stale composing range after text is replaced mid-composition (flutter/flutter#194096) 2026-10-14 [email protected] Roll Skia from 2a2bbea66844 to acde3755d2e2 (1 revision) (flutter/flutter#194376) 2026-10-14 [email protected] Roll Skia from 128c983b12de to 2a2bbea66844 (1 revision) (flutter/flutter#194371) 2026-10-14 [email protected] Roll Skia from 48a294ed4955 to 128c983b12de (3 revisions) (flutter/flutter#194353) 2026-10-14 [email protected] feat(flutter_tools): extract WebDebugConfig from DebuggingOptions (flutter/flutter#194312) 2026-10-14 [email protected] Roll Skia from ea6781c5b6d1 to 48a294ed4955 (2 revisions) (flutter/flutter#194349) 2026-10-14 [email protected] Include <vector> in Android proc_table.h. (flutter/flutter#194325) 2026-10-14 [email protected] Roll Dart SDK from 5933cb486b4a to 6b50116630d0 (28 revisions) (flutter/flutter#194341) 2026-10-14 [email protected] Move GLES3 instancing API entry points to FOR_EACH_IMPELLER_GLES3_PROC (flutter/flutter#194319) 2026-10-14 [email protected] feat(flutter_tools): extract AndroidGradleConfig and move toGradleConfig to AndroidBuildInfo (flutter/flutter#194016) 2026-10-14 [email protected] Roll Skia from ae297bec6012 to ea6781c5b6d1 (8 revisions) (flutter/flutter#194331) 2026-10-14 [email protected] [flutter_tools] Migrate gradle_errors and deferred_components_prebuild_validator away from globals (flutter/flutter#193649) 2026-10-14 [email protected] [Impeller] Cache GLES sampler configuration in RenderPassStateCache (flutter/flutter#193922) 2026-10-14 [email protected] Roll pub packages (flutter/flutter#194332) 2026-10-13 [email protected] [tool] Migrate RunCommand to modular dependency injection (flutter/flutter#190791) 2026-10-13 [email protected] Include `engine/src/flutter/.ci.yaml` in quarterly `goldctl` checklist (flutter/flutter#194316) 2026-10-13 [email protected] [flutter_tools] Remove the last AMD module system support (flutter/flutter#193607) 2026-10-13 [email protected] Roll Skia from 8b3394a60654 to ae297bec6012 (5 revisions) (flutter/flutter#194310) 2026-10-13 [email protected] [web] Remove the a11y placeholder only after the gesture ends (flutter/flutter#194109) 2026-10-13 [email protected] Upgrade goldctl to the latest version (flutter/flutter#193932) 2026-10-13 [email protected] [flutter_tools] Lazily initialize AndroidStudio validation and optimize candidate selection (flutter/flutter#191968) 2026-10-13 [email protected] [flutter_tools] Clean up outdated widget preview TODOs and refactor static state (flutter/flutter#189437) 2026-10-13 [email protected] Roll Skia from e5b5db6d0d6f to 8b3394a60654 (2 revisions) (flutter/flutter#194306) 2026-10-13 [email protected] Redistribute TESTOWNERS for Android team (flutter/flutter#193861) 2026-10-13 [email protected] feat(flutter_tools): introduce Test and Drive specification objects (flutter/flutter#194017) 2026-10-13 [email protected] [Impeller] Keep the aspect ratio when shrinking images to the max texture size (flutter/flutter#194010) 2026-10-13 [email protected] [flutter tool] preserve inherited `DASH__SUPPRESS_ANALYTICS=true` for sub-tools (flutter/flutter#194261) 2026-10-13 [email protected] Roll Packages from d8d9e97 to a1ed23c (9 revisions) (flutter/flutter#194302) 2026-10-13 [email protected] Use PE/COFF AOT snapshots for Windows x64 (flutter/flutter#187594) 2026-10-13 [email protected] Fix Expansible crash when PageStorage holds a non-bool value (flutter/flutter#192195) 2026-10-13 [email protected] Roll Skia from ffeccb3ca58a to e5b5db6d0d6f (1 revision) (flutter/flutter#194297) 2026-10-13 [email protected] Explain why initState() is too early to depend on an inherited widget (flutter/flutter#192727) 2026-10-13 [email protected] Refactor TestPlatformDispatcher (flutter/flutter#192747) 2026-10-13 [email protected] Roll Skia from 3de0984208ec to ffeccb3ca58a (2 revisions) (flutter/flutter#194291) 2026-10-13 [email protected] Roll Skia from 0580c2b780f6 to 3de0984208ec (2 revisions) (flutter/flutter#194281) 2026-10-13 [email protected] Roll Skia from f641d55e07a8 to 0580c2b780f6 (3 revisions) (flutter/flutter#194275) 2026-10-13 [email protected] Roll Skia from 0e5d8d1be81b to f641d55e07a8 (1 revision) (flutter/flutter#194266) 2026-10-13 [email protected] Scaffold view metrics overrides (flutter/flutter#192764) 2026-10-13 [email protected] [web] Add SemanticsRole.listBox and SemanticsRole.option (flutter/flutter#192971) 2026-10-13 [email protected] Pin mac_unopt to macOS 15 (flutter/flutter#194254) 2026-10-13 [email protected] Roll pub packages (flutter/flutter#194257) 2026-10-12 [email protected] Roll Skia from 17f6986c226c to 0e5d8d1be81b (4 revisions) (flutter/flutter#194249) 2026-10-12 [email protected] Make DisplayLists' use of DlPaint, SkPaint, and impeller::Paint agree on the default isAntiAlias (flutter/flutter#193939) If this roll has caused a breakage, revert this CL and set the roller ...
…fig to AndroidBuildInfo (flutter#194016) ### Rationale `BuildInfo` is the cross-platform build configuration passed across Android, iOS, Web, Desktop, and Fuchsia targets, yet it carried 6 loose Android/Gradle fields (`androidProjectArgs`, `androidGradleProjectCacheDir`, `androidGradleDaemon`, `androidSkipBuildDependencyValidation`, `androidEnableHcpp`, `explicitAndroidEnableHcpp`) and the Gradle `-P` flag serializer `toGradleConfig()`. Following flutter#191018, flutter#191510, flutter#191760, flutter#192307, flutter#192455, flutter#192524, flutter#192818, and flutter#193323, this change encapsulates those fields into `AndroidGradleConfig` and moves `toGradleConfig()` onto `AndroidBuildInfo` where all production callers already operate. ### Summary of Changes - Introduce `@immutable class AndroidGradleConfig` in `build_info.dart` and replace the 6 loose `android*` parameters on `BuildInfo` and `BuildInfo.copyWith` with `androidGradleConfig` (shrinking `BuildInfo`'s constructor from 28 to 23 parameters while preserving `AndroidDevice.startApp` forwarding during `flutter run`). - Move `toGradleConfig()` off `BuildInfo` onto `AndroidBuildInfo` (with zero `@deprecated` forwarders) and add `gradleDaemon` and `skipBuildDependencyValidation` convenience getters on `AndroidBuildInfo`. - Update `FlutterCommand.getBuildInfo()` in `flutter_command.dart` to construct `AndroidGradleConfig`. - Update `buildGradleApp`, `buildGradleAar`, and `_checkJavaAndGradleCompatibility` in `gradle.dart` to read Gradle configuration via `AndroidBuildInfo`. - Update unit tests across `build_info_test.dart`, `flutter_command_test.dart`, `android_gradle_builder_test.dart`, and `build_aar_test.dart`. ### Flow / Surface Delta ```mermaid flowchart LR A["FlutterCommand.getBuildInfo()"] --> B["BuildInfo(androidGradleConfig)"] B --> C["AndroidBuildInfo.toGradleConfig()"] C --> D["gradle.dart (-P flags)"] ``` ### Verification - Executed `dart analyze --fatal-infos` on `packages/flutter_tools` with 0 issues. - Executed `dart test` across `build_info_test.dart`, `flutter_command_test.dart`, `android_gradle_builder_test.dart`, and `build_aar_test.dart` (`160/160` passing). ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
Rationale
BuildInfois the cross-platform build configuration passed across Android, iOS, Web, Desktop, and Fuchsia targets, yet it carried 6 loose Android/Gradle fields (androidProjectArgs,androidGradleProjectCacheDir,androidGradleDaemon,androidSkipBuildDependencyValidation,androidEnableHcpp,explicitAndroidEnableHcpp) and the Gradle-Pflag serializertoGradleConfig(). Following #191018, #191510, #191760, #192307, #192455, #192524, #192818, and #193323, this change encapsulates those fields intoAndroidGradleConfigand movestoGradleConfig()ontoAndroidBuildInfowhere all production callers already operate.Summary of Changes
@immutable class AndroidGradleConfiginbuild_info.dartand replace the 6 looseandroid*parameters onBuildInfoandBuildInfo.copyWithwithandroidGradleConfig(shrinkingBuildInfo's constructor from 28 to 23 parameters while preservingAndroidDevice.startAppforwarding duringflutter run).toGradleConfig()offBuildInfoontoAndroidBuildInfo(with zero@deprecatedforwarders) and addgradleDaemonandskipBuildDependencyValidationconvenience getters onAndroidBuildInfo.FlutterCommand.getBuildInfo()influtter_command.dartto constructAndroidGradleConfig.buildGradleApp,buildGradleAar, and_checkJavaAndGradleCompatibilityingradle.dartto read Gradle configuration viaAndroidBuildInfo.build_info_test.dart,flutter_command_test.dart,android_gradle_builder_test.dart, andbuild_aar_test.dart.Flow / Surface Delta
flowchart LR A["FlutterCommand.getBuildInfo()"] --> B["BuildInfo(androidGradleConfig)"] B --> C["AndroidBuildInfo.toGradleConfig()"] C --> D["gradle.dart (-P flags)"]Verification
dart analyze --fatal-infosonpackages/flutter_toolswith 0 issues.dart testacrossbuild_info_test.dart,flutter_command_test.dart,android_gradle_builder_test.dart, andbuild_aar_test.dart(160/160passing).Pre-launch Checklist
///).