Skip to content

[tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection - #190773

Merged
auto-submit[bot] merged 11 commits into
flutter:masterfrom
bkonyi:di/13-assemble-generate
Sep 4, 2026
Merged

auto-submit[bot] merged 11 commits into
flutter:masterfrom
bkonyi:di/13-assemble-generate

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 13 of the modular dependency injection migration.

  • Migrates AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand to constructor dependency injection:
    • AssembleCommand({required BuildSystem buildSystem, required FeatureFlags featureFlags, required ToolContext toolContext, bool verboseHelp = false})
    • GenerateCommand({required ToolContext toolContext})
    • GenerateLocalizationsCommand({required ToolContext toolContext})
  • Eliminates globals.featureFlags and ambient context lookups across assemble/generate workflows; exposes featureFlags on ToolDependencies.
  • Requires explicit logger in parseLocalizationsOptionsFromCommand and explicit featureFlags in artifactFromTargetPlatform.
  • Migrates unit tests in packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart and generate_localizations_test.dart to hermetic testWithoutContext.

Part of #188471

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 8, 2026
@bkonyi
bkonyi force-pushed the di/13-assemble-generate branch 5 times, most recently from b9fe2b9 to 8062f50 Compare August 12, 2026 18:17
@github-actions github-actions Bot removed the team-android Owned by Android platform team label Aug 12, 2026
@bkonyi
bkonyi force-pushed the di/13-assemble-generate branch from 8062f50 to 383c5e7 Compare August 12, 2026 18:39
@bkonyi
bkonyi force-pushed the di/13-assemble-generate branch from 383c5e7 to 2c5bd8c Compare September 2, 2026 13:20
@bkonyi
bkonyi marked this pull request as ready for review September 2, 2026 13:20
@bkonyi bkonyi added the CICD Run CI/CD label Sep 2, 2026
@github-actions github-actions Bot removed team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Sep 2, 2026
@bkonyi
bkonyi force-pushed the di/13-assemble-generate branch from 2c5bd8c to de02f0d Compare September 2, 2026 13: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 several Flutter commands, including AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand, to accept and utilize a ToolContext instead of relying on global variables. This refactoring enables the migration of associated tests from testUsingContext to testWithoutContext by injecting mock dependencies. Feedback on the changes identifies that defaulting to true when featureFlags is null in artifactFromTargetPlatform is a testing anti-pattern that bypasses production checks, and suggests falling back to globals.featureFlags instead.

Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 several Flutter tool commands, including AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand, to accept and utilize a ToolContext instead of relying on global variables. This change enables migrating associated tests from testUsingContext to testWithoutContext by directly injecting fake or mock contexts. The review feedback suggests removing the redundant _flutterProject field in AssembleCommand in favor of the inherited project getter, and renaming the featureFlags parameter in artifactFromTargetPlatform to prevent shadowing the global getter.

Comment thread packages/flutter_tools/lib/src/commands/assemble.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 several Flutter commands, including AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand, to accept a ToolContext rather than relying on global variables or individual dependency parameters. Correspondingly, unit tests are migrated from testUsingContext to testWithoutContext by utilizing a FakeToolContext. Feedback on the changes suggests simplifying AssembleCommand by removing the redundant _effectiveAnalytics getter and using the inherited analytics property directly.

Comment thread packages/flutter_tools/lib/src/commands/assemble.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/assemble.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/assemble.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand to accept dependencies via a ToolContext parameter rather than relying on global context, enabling the migration of associated tests from testUsingContext to testWithoutContext. The review feedback suggests caching the project getter in AssembleCommand._createEnvironment and caching the l10n.yaml file reference in GenerateLocalizationsCommand.runCommand to avoid redundant lookups and object creation.

Comment thread packages/flutter_tools/lib/src/commands/assemble.dart
Comment thread packages/flutter_tools/lib/src/commands/generate_localizations.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand to accept and utilize a ToolContext instead of relying on global variables, improving dependency injection and allowing tests to be migrated from testUsingContext to testWithoutContext. Feedback suggests overriding the hidden property to true in GenerateCommand to satisfy the new test assertions, and extracting the repeated customFeatureFlags ?? globals.featureFlags expression in flutter_command.dart into a local variable for better readability.

Comment thread packages/flutter_tools/lib/src/commands/generate.dart
Comment thread packages/flutter_tools/lib/src/runner/flutter_command.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 AssembleCommand, GenerateCommand, and GenerateLocalizationsCommand to accept and utilize a ToolContext instead of relying on global variables from globals.dart. Consequently, the associated hermetic tests in assemble_test.dart and generate_localizations_test.dart are migrated from testUsingContext to testWithoutContext using a FakeToolContext to inject dependencies. Additionally, FlutterCommand.project is updated to resolve the project from the file system using _projectFactory rather than FlutterProject.current(). No review comments were provided for this pull request, so there is no feedback to evaluate.

@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@bkonyi
bkonyi requested a review from chingjun September 4, 2026 20:04
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 4, 2026
Merged via the queue into flutter:master with commit 079138d Sep 4, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 5, 2026
flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [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
pull Bot pushed a commit to fucheng-guo-sun/flutter that referenced this pull request Sep 8, 2026
Desktop builds with --local-engine quietly used the cached engine
instead of the one just built, and often failed outright with "Can't
load Kernel binary: Invalid SDK hash", because cached engine artifacts
stop being updated once --local-engine is used and eventually no longer
match the Dart SDK.

Commands are created with the artifacts to build against when the tool
starts up, which is before the command line has been parsed, so they
always used the cached ones. --local-engine and --local-web-sdk were
applied afterwards, and only to the legacy zone that commands used to
read artifacts from. flutter assemble stopped reading from that zone in
flutter#190773, taking the build system with it.

Use artifacts that can be changed after they are created instead, and
update them as soon as the runner has parsed the command line, which
happens before any command runs. Everything then builds against the
right engine.
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [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
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