Skip to content

[flutter_tools] Migrate BuildBundleCommand to modular dependency injection - #192462

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:di/17a-build-bundle-command
Sep 15, 2026
Merged

auto-submit[bot] merged 9 commits into
flutter:masterfrom
bkonyi:di/17a-build-bundle-command

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR splits BuildBundleCommand migration out of #190783 (part of modular dependency injection migration in flutter_tools).

  • Migrates BuildBundleCommand to modular dependency injection with BuildSystem, FeatureFlags, and ToolContext.
  • Exposes FeatureFlags? featureFlags on FlutterCommandRunner.
  • Updates FlutterCommand.targetFile to use toolContext?.fs.
  • Converted build_bundle_test.dart from permeable context tests to hermetic testWithoutContext tests.

…ction

Migrate `BuildBundleCommand` to modular dependency injection, removing ambient globals from `build_bundle.dart` and moving tests to hermetic `testWithoutContext`.
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 9, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 9, 2026

@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 BuildBundleCommand to inject dependencies such as BuildSystem, FeatureFlags, and ToolContext instead of relying on global context. It also migrates the bundle build tests to a hermetic setup using testWithoutContext and deletes the old context-based test file. Feedback on the changes suggests extracting duplicated FeatureFlags lookup logic in FlutterCommand into a private helper getter to improve maintainability, and removing a redundant @visibleForTesting annotation in the test's FakeBundleBuilder to align with the base class.

Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
Comment thread packages/flutter_tools/test/commands.shard/hermetic/build_bundle_test.dart Outdated
@bkonyi
bkonyi requested a review from chingjun September 11, 2026 14:54
chingjun
chingjun previously approved these changes Sep 11, 2026

@dcharkes dcharkes 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.

approving after merge and format

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 15, 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 8737f11 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
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Sep 29, 2026
…ncy injection (flutter#190783)

## Summary

Part 17 of the modular dependency injection migration.

> [!NOTE]
> Stacked on [flutter#192462](flutter#192462)
(`di/17a-build-bundle-command`), which migrated `BuildBundleCommand` to
modular DI.

* Migrates Web build subcommand and toolchain components to modular
constructor dependency injection:
- `BuildWebCommand({required BuildSystem buildSystem, required
FeatureFlags featureFlags, required ToolContext toolContext, required
super.verboseHelp, BuildTargets buildTargets = const BuildTargetsImpl(),
WebBuilder? webBuilder})`
* Passes `ToolContext` directly to subcommands, eliminating
`context.get` fallbacks in `BuildCommand` and `WebBuilder`.
* Injects `FileSystem` into `defaultDepfilePath` and
`getAssetBuildDirectory`.
* Migrates unit tests in
`test/commands.shard/hermetic/build_web_test.dart` to hermetic
`testWithoutContext`.

Part of flutter#188471
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.

3 participants