Skip to content

flutter build <meta-build> is incompatible with dev-dependency plugin optimizations #162649

@matanlurey

Description

@matanlurey

Was debugging #160289 with @camsim99 and @jonahwilliams the Flutter historian.

The tl;dr is if you enable flutter config --explicit-package-dependencies, and try using flutter build aar, an error is always thrown:

$ flutter config --explicit-package-dependencies

# Create and navigate to a project that uses `flutter build aar`
# An example is the `build_aar_module_test.dart` in dev/devicelab
$ flutter build aar

With this flag, you will always see the following output:

flutter build aar
Only one of "--debug", "--profile", "--jit-release", or "--release" can be specified.

Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

The reason for this error is because we check the build mode as part of --explicit-package-dependencies:

await project.regeneratePlatformSpecificTooling(
allowedPlugins: allowedPlugins,
releaseMode: featureFlags.isExplicitPackageDependenciesEnabled && getBuildMode().isRelease,
);

Unfortunately, flutter build aar (and we suspect, flutter build ios-framework and flutter build macos-framework?) don't work like a typical flutter build, instead of specifying the build mode (or having it inferred based on the context, i.e. run means --debug and build means --release), these commands build all three outputs unless specified otherwise (i.e. flutter build aar --no-profile --no-debug will only build a release mode artifact).

We have a few options for "working around" this:

  1. Never apply plugin optimizations to these scenarios. That is, flutter build aar, even the release artifact, includes dev plugins.
  2. Change the behavior of flutter build aar (and similar commands) to build three outputs in serial instead of re-using the build configurations
  3. Change the behavior of flutter build aar (and similar commands) to build a single output, with the same semantics as flutter build normally.

We could do (1) as a placeholder until it is feasible to write and test (2), but either way we need a resolution ASAP to unblock this set of features.

Sub-issues

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.fyi-iosFor the attention of iOS platform teamfyi-toolFor the attention of Flutter Tool teamplatform-androidAndroid applications specificallyteam-androidOwned by Android platform team

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions