Repository navigation
feat(flutter_tools): migrate Android build commands to typed options - #192524
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors option registration in several Android build commands (build_aar, build_apk, and build_appbundle) to use centralized option bundles and descriptors, simplifying command constructors and option definitions. The review feedback suggests further grouping option descriptors in BuildAarCommand and avoiding duplicate retrieval of the target platform value in BuildApkCommand by using a local variable.
|
autosubmit label was removed for flutter/flutter/192524, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/192524, because Pull request flutter/flutter/192524 is not in a mergeable state. |
Migrates `build apk`, `build appbundle`, and `build aar` subcommands to use typed option descriptors and option bundles. - Adds `BuildInfoOptions.shrink` and `BuildInfoOptions.ignoreDeprecation` descriptors. - Adds `AndroidGradleOptionsBundle` for the 4 Gradle project options: daemon, skip dependency validation, project args, and project cache dir. - Adds `AndroidBuildOptionsBundle` composing Gradle options with common Android build flags. - Moves `CommonOptions.outputDir` from `CommonBuildOptionsBundle` to `WebCoreOptionsBundle` and `build aar`, and moves `CommonOptions.nativeNullAssertions` from `DartCompileOptionsBundle` to `WebJsOptionsBundle`. - Migrates command constructors to `registerOptionBundles` and `argParser.addDescriptors`. - Migrates option reads to `getValue(...)` via `SafeArgResults`. - Adds unit tests for `AndroidBuildOptionsBundle` in `option_descriptor_test.dart`.
- Remove local defaulted _buildNumber in build_aar in favor of CommonOptions.buildNumber to prevent overriding manifest build number in getBuildInfo() Dart defines - Mark Android Gradle build options as verboseOnly: true in BuildInfoOptions to match legacy hide: !verboseHelp behavior - Expand unit tests to verify verbose hiding of AndroidGradleOptionsBundle and all 16 descriptors in AndroidBuildOptionsBundle
…options - Include trackWidgetCreation directly in argParser.addDescriptors in build_aar - Cache getValue(_targetPlatform) in local variable in build_apk._targetArchs
- Iterate directly over FlagOptionDescriptors and derive buildMode from descriptor.name instead of creating record tuples
02a2f11 to
00a39ea
Compare
|
@bkonyi another nod, please! 🙏 |
…12890) Manual roll requested by [email protected] flutter/flutter@27fec0e...8737f11 2026-09-15 [email protected] [flutter_tools] Migrate BuildBundleCommand to modular dependency injection (flutter/flutter#192462) 2026-09-15 [email protected] Migrate SDK constraints for record_use and data_asset integration test packages to ^3.13.0-0 (flutter/flutter#192728) 2026-09-15 [email protected] [tool] Defer app.restart until the app has finished starting (flutter/flutter#192650) 2026-09-15 [email protected] Suggest the -d flag after interactive device selection (flutter/flutter#188941) 2026-09-15 [email protected] Roll Packages from 9caa77c to bebbb57 (9 revisions) (flutter/flutter#192809) 2026-09-15 [email protected] Add a compiler warning for fragment shaders containing both texture samplers and early returns. (flutter/flutter#191969) 2026-09-15 [email protected] feat(flutter_tools): migrate Android build commands to typed options (flutter/flutter#192524) 2026-09-15 [email protected] Roll Fuchsia Linux SDK from 7R1l5MhSZZUr1Q6D1... to XCxrICzX1DWvyfqhA... (flutter/flutter#192789) 2026-09-15 [email protected] Roll Dart SDK from 7253dff72c96 to c870e8afe036 (1 revision) (flutter/flutter#192791) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#193323) Migrate `BuildLinuxCommand` (`build linux`) and `BuildWindowsCommand` (`build windows`) to typed `OptionDescriptor`s and `OptionBundle`s (following flutter#191018, flutter#191510, flutter#191760, flutter#192307, flutter#192455, flutter#192524, and flutter#192818): - Add `DesktopBuildOptionsBundle` in `common_options.dart`, encapsulating `CommonBuildOptionsBundle`, `BuildModeOptionsBundle`, `DartCompileOptionsBundle`, `BuildInfoOptions.flavor`, `splitDebugInfo`, `obfuscate`, `extraFrontEndOptions`, `extraGenSnapshotOptions`, `performanceMeasurementFile`, `analyzeSize`, `codeSizeDirectory`, `trackWidgetCreation`, and `configOnly`. - Migrate `BuildLinuxCommand` (`build_linux.dart`) to `DesktopBuildOptionsBundle`, `DefaultedEnumOptionDescriptor<TargetPlatform>` (`_targetPlatformOption`), and `DefaultedStringOptionDescriptor` (`_targetSysroot`), replacing untyped `boolArg('config-only')`, `stringArg('target-platform')!`, and `stringArg('target-sysroot')!` queries. - Migrate `BuildWindowsCommand` (`build_windows.dart`) to `DesktopBuildOptionsBundle` and `getValue(DesktopBuildOptionsBundle.configOnly)`. - Delete the obsolete `FlutterCommand.addCommonDesktopBuildOptions` helper method from `flutter_command.dart` (no remaining callers in `flutter_tools`). ## 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.
Migrates
build apk,build appbundle, andbuild aarsubcommands to use typed option descriptors and option bundles.BuildInfoOptions.shrinkandBuildInfoOptions.ignoreDeprecationdescriptors.AndroidGradleOptionsBundlefor the 4 Gradle project options (daemon, skip dependency validation, project args, and project cache dir), preserving theirverboseOnly: truehelp hiding behavior.AndroidBuildOptionsBundlecomposing Gradle options with common Android build flags.CommonOptions.buildNumberinbuild aarto ensure consistent Dart define behavior inFlutterCommand.getBuildInfo().addShrinkingFlaghelper fromFlutterCommandas all callers have migrated.CommonOptions.outputDirfromCommonBuildOptionsBundletoWebCoreOptionsBundleandbuild aar, and movesCommonOptions.nativeNullAssertionsfromDartCompileOptionsBundletoWebJsOptionsBundle.registerOptionBundlesandargParser.addDescriptors.getValue(...)viaSafeArgResults.AndroidGradleOptionsBundleandAndroidBuildOptionsBundleinoption_descriptor_test.dart.Pre-launch Checklist
///).