flutter build aar regenerates tooling between each build-mode step (#162705)

Closes https://github.com/flutter/flutter/issues/162703.

I still need to do a similar change for `ios|macos`-`framework` in
https://github.com/flutter/flutter/issues/162704.

I added two unit tests, as well as opted in an integration test to the
flag (it will become the default in
https://github.com/flutter/flutter/pull/160289).

/cc @reidbaker @gmackall.
This commit is contained in:
Matan Lurey
2025-02-06 09:03:02 -08:00
committed by GitHub
parent f219bbac55
commit 0e59f0f64c
9 changed files with 363 additions and 89 deletions

View File

@@ -20,6 +20,7 @@ class FakeAndroidBuilder implements AndroidBuilder {
required FlutterProject project,
required Set<AndroidBuildInfo> androidBuildInfo,
required String target,
required Future<void> Function(FlutterProject, {required bool releaseMode}) generateTooling,
String? outputDirectoryPath,
required String buildNumber,
}) async {}

View File

@@ -16,10 +16,15 @@ final class FakePubWithPrimedDeps implements Pub {
/// dev-dependencies ([dependencies]) of any package to a set of any other
/// packages. A resulting valid `dart pub deps --json` response is implicitly
/// created.
///
/// If [allowGet] is `true`, [Pub.get] can be invoked (all the parameters are
/// ignored and it is considered a success); otherwise an error is thrown to
/// reject an unexpected call.
factory FakePubWithPrimedDeps({
String rootPackageName = 'app_name',
Set<String> devDependencies = const <String>{},
Map<String, Set<String>> dependencies = const <String, Set<String>>{},
bool allowGet = false,
}) {
// Start the packages: [ ... ] list with the root package.
final List<Object?> packages = <Object?>[
@@ -56,11 +61,34 @@ final class FakePubWithPrimedDeps implements Pub {
return FakePubWithPrimedDeps._(<String, Object?>{
'root': rootPackageName,
'packages': packages,
});
}, allowGetToSucceed: allowGet);
}
const FakePubWithPrimedDeps._(this._deps);
const FakePubWithPrimedDeps._(this._deps, {required bool allowGetToSucceed})
: _allowGetToSucceed = allowGetToSucceed;
final Map<String, Object?> _deps;
final bool _allowGetToSucceed;
@override
Future<void> get({
required PubContext context,
required FlutterProject project,
bool upgrade = false,
bool offline = false,
String? flutterRootOverride,
bool checkUpToDate = false,
bool shouldSkipThirdPartyGenerator = true,
PubOutputMode outputMode = PubOutputMode.all,
}) async {
if (_allowGetToSucceed) {
return;
}
throw UnsupportedError(
'Instance did not expect <Pub>.get to be invoked. If this was intentional, '
'change the constructor of FakePubWithPrimeDeps to include the parameter '
'allowGet: true.',
);
}
@override
Future<Map<String, Object?>> deps(FlutterProject project) async => _deps;