Skip to content

feat(flutter_tools): migrate Android build commands to typed options - #192524

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
kevmoo:pr5-android-build-options
Sep 15, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
kevmoo:pr5-android-build-options

Conversation

@kevmoo

@kevmoo kevmoo commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

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), preserving their verboseOnly: true help hiding behavior.
  • Adds AndroidBuildOptionsBundle composing Gradle options with common Android build flags.
  • Reuses CommonOptions.buildNumber in build aar to ensure consistent Dart define behavior in FlutterCommand.getBuildInfo().
  • Removes obsolete addShrinkingFlag helper from FlutterCommand as all callers have migrated.
  • 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 AndroidGradleOptionsBundle and AndroidBuildOptionsBundle in option_descriptor_test.dart.

Pre-launch Checklist

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 10, 2026
@kevmoo
kevmoo requested a review from bkonyi September 10, 2026 02:20
@kevmoo
kevmoo marked this pull request as ready for review September 10, 2026 02:21

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/flutter_tools/lib/src/commands/build_aar.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build_apk.dart Outdated
@kevmoo kevmoo added the CICD Run CI/CD label Sep 10, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one comment.

Comment thread packages/flutter_tools/lib/src/commands/build_aar.dart Outdated
bkonyi
bkonyi previously approved these changes Sep 10, 2026
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit

auto-submit Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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.

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit

auto-submit Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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
@kevmoo

kevmoo commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

@bkonyi another nod, please! 🙏

@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 13, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 15, 2026
Merged via the queue into flutter:master with commit 4762dec Sep 15, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 15, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 17, 2026
…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
@kevmoo
kevmoo deleted the pr5-android-build-options branch September 18, 2026 06:03
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Oct 8, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants