Skip to content

Commit 7cc1caa

Browse files
[tool] Update build-all app creation (flutter#7955)
Minor cleanup of the script to create the build-all app, mostly for Android: - Don't override the minSdk to 21, since the Flutter-provided value is now 21 already. - Don't enable multidex, since that isn't necessary for minSdk 20+. - Remove camera_android_camerax from the direct dependency list, not camera_android, now that the endorsement has switched. This will return us to the previous, intended behavior of testing that both versions build together. - If for some reason the Dart SDK isn't detected, use 3.0.0+ instead of 2.12.0+.
1 parent e12e073 commit 7cc1caa

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

script/tool/lib/src/create_all_packages_app_command.dart

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,9 @@ dependencies {}
245245
if (gradleFileIsKotlin)
246246
'compileSdk': <String>['compileSdk = 34']
247247
else ...<String, List<String>>{
248-
// minSdkVersion 21 is required by camera_android.
249-
'minSdkVersion': <String>['minSdkVersion 21'],
250248
'compileSdkVersion': <String>['compileSdk 34'],
251249
}
252250
},
253-
additions: <String, List<String>>{
254-
'defaultConfig {': <String>[
255-
if (gradleFileIsKotlin)
256-
' multiDexEnabled = true'
257-
else
258-
' multiDexEnabled true'
259-
],
260-
},
261251
regexReplacements: <RegExp, List<String>>{
262252
// Tests for https://github.com/flutter/flutter/issues/43383
263253
// Handling of 'dependencies' is more complex since it hasn't been very
@@ -289,7 +279,7 @@ dependencies {}
289279
final VersionConstraint dartSdkConstraint =
290280
originalPubspec.environment?[dartSdkKey] ??
291281
VersionConstraint.compatibleWith(
292-
Version.parse('2.12.0'),
282+
Version.parse('3.0.0'),
293283
);
294284

295285
final Map<String, PathDependency> pluginDeps =
@@ -313,15 +303,15 @@ dependencies {}
313303
// An application cannot depend directly on multiple federated
314304
// implementations of the same plugin for the same platform, which means the
315305
// app cannot directly depend on both camera_android and
316-
// camera_android_androidx. Since camera_android is endorsed, it will be
317-
// included transitively already, so exclude it from the direct dependency
318-
// list to allow including camera_android_androidx to ensure that they don't
319-
// conflict at build time (if they did, it would be impossible to use
320-
// camera_android_androidx while camera_android is endorsed).
306+
// camera_android_androidx. Since camera_android_androidx is endorsed, it
307+
// will be included transitively already, so exclude it from the direct
308+
// dependency list to allow including camera_android to ensure that they
309+
// don't conflict at build time (if they did, it would be impossible to use
310+
// camera_android while camera_android_androidx is endorsed).
321311
// This is special-cased here, rather than being done via the normal
322312
// exclusion config file mechanism, because it still needs to be in the
323313
// depenedency overrides list to ensure that the version from path is used.
324-
pubspec.dependencies.remove('camera_android');
314+
pubspec.dependencies.remove('camera_android_camerax');
325315

326316
app.pubspecFile.writeAsStringSync(_pubspecToString(pubspec));
327317
}

script/tool/test/create_all_packages_app_command_test.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ project 'Runner', {
222222
});
223223

224224
test(
225-
'pubspec special-cases camera_android to remove it from deps but not overrides',
225+
'pubspec special-cases camera_android_camerax to remove it from deps but not overrides',
226226
() async {
227227
writeFakeFlutterCreateOutput(testRoot);
228228
final Directory cameraDir = packagesDir.childDirectory('camera');
@@ -241,16 +241,16 @@ project 'Runner', {
241241
expect(cameraDependency, isA<PathDependency>());
242242
expect((cameraDependency! as PathDependency).path,
243243
endsWith('/packages/camera/camera'));
244-
expect(cameraCameraXDependency, isA<PathDependency>());
245-
expect((cameraCameraXDependency! as PathDependency).path,
246-
endsWith('/packages/camera/camera_android_camerax'));
247-
expect(cameraAndroidDependency, null);
248-
249-
final Dependency? cameraAndroidOverride =
250-
pubspec.dependencyOverrides['camera_android'];
251-
expect(cameraAndroidOverride, isA<PathDependency>());
252-
expect((cameraAndroidOverride! as PathDependency).path,
244+
expect(cameraAndroidDependency, isA<PathDependency>());
245+
expect((cameraAndroidDependency! as PathDependency).path,
253246
endsWith('/packages/camera/camera_android'));
247+
expect(cameraCameraXDependency, null);
248+
249+
final Dependency? cameraCameraXOverride =
250+
pubspec.dependencyOverrides['camera_android_camerax'];
251+
expect(cameraCameraXOverride, isA<PathDependency>());
252+
expect((cameraCameraXOverride! as PathDependency).path,
253+
endsWith('/packages/camera/camera_android_camerax'));
254254
});
255255

256256
test('legacy files are copied when requested', () async {
@@ -342,7 +342,6 @@ android {
342342
buildGradle,
343343
containsAll(<Matcher>[
344344
contains('This is the legacy file'),
345-
contains('minSdkVersion 21'),
346345
contains('compileSdk 34'),
347346
]));
348347
});
@@ -376,9 +375,7 @@ android {
376375
expect(
377376
buildGradle,
378377
containsAll(<Matcher>[
379-
contains('minSdkVersion 21'),
380378
contains('compileSdk 34'),
381-
contains('multiDexEnabled true'),
382379
contains('androidx.lifecycle:lifecycle-runtime'),
383380
]));
384381
});

0 commit comments

Comments
 (0)