Impacted Users: iOS and macOS Flutter developers Impact Description: iOS/macOS workflows may not behave as expected due to missing dev dependencies. Workaround: Yes, run in debug mode, such as `flutter build ios --debug --config-only` Risk: low Test Coverage: yes Validation Steps: Run `flutter build ios` on a project with dev dependencies and should see them in the GeneratedPluginRegistrant
This commit is contained in:
parent
fdefa52cef
commit
f3eca332f3
@ -1250,37 +1250,51 @@ Future<void> injectPlugins(
|
|||||||
bool windowsPlatform = false,
|
bool windowsPlatform = false,
|
||||||
DarwinDependencyManagement? darwinDependencyManagement,
|
DarwinDependencyManagement? darwinDependencyManagement,
|
||||||
}) async {
|
}) async {
|
||||||
List<Plugin> plugins = await findPlugins(project);
|
final List<Plugin> plugins = await findPlugins(project);
|
||||||
|
|
||||||
|
// Filter out dev dependencies for release builds.
|
||||||
|
final List<Plugin> filteredPlugins;
|
||||||
if (releaseMode) {
|
if (releaseMode) {
|
||||||
plugins = plugins.where((Plugin p) => !p.isDevDependency).toList();
|
filteredPlugins = plugins.where((Plugin p) => !p.isDevDependency).toList();
|
||||||
|
} else {
|
||||||
|
filteredPlugins = plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, List<Plugin>> pluginsByPlatform = _resolvePluginImplementations(
|
final Map<String, List<Plugin>> filteredPluginsByPlatform = _resolvePluginImplementations(
|
||||||
plugins,
|
filteredPlugins,
|
||||||
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (androidPlatform) {
|
if (androidPlatform) {
|
||||||
await _writeAndroidPluginRegistrant(project, pluginsByPlatform[AndroidPlugin.kConfigKey]!);
|
await _writeAndroidPluginRegistrant(
|
||||||
}
|
project,
|
||||||
if (iosPlatform) {
|
filteredPluginsByPlatform[AndroidPlugin.kConfigKey]!,
|
||||||
await _writeIOSPluginRegistrant(project, pluginsByPlatform[IOSPlugin.kConfigKey]!);
|
);
|
||||||
}
|
}
|
||||||
if (linuxPlatform) {
|
if (linuxPlatform) {
|
||||||
await _writeLinuxPluginFiles(project, pluginsByPlatform[LinuxPlugin.kConfigKey]!);
|
await _writeLinuxPluginFiles(project, filteredPluginsByPlatform[LinuxPlugin.kConfigKey]!);
|
||||||
}
|
|
||||||
if (macOSPlatform) {
|
|
||||||
await _writeMacOSPluginRegistrant(project, pluginsByPlatform[MacOSPlugin.kConfigKey]!);
|
|
||||||
}
|
}
|
||||||
if (windowsPlatform) {
|
if (windowsPlatform) {
|
||||||
await writeWindowsPluginFiles(
|
await writeWindowsPluginFiles(
|
||||||
project,
|
project,
|
||||||
pluginsByPlatform[WindowsPlugin.kConfigKey]!,
|
filteredPluginsByPlatform[WindowsPlugin.kConfigKey]!,
|
||||||
globals.templateRenderer,
|
globals.templateRenderer,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iosPlatform || macOSPlatform) {
|
if (iosPlatform || macOSPlatform) {
|
||||||
|
// iOS and macOS doesn't yet support filtering out dev dependencies.
|
||||||
|
// See https://github.com/flutter/flutter/issues/163874.
|
||||||
|
final Map<String, List<Plugin>> pluginsByPlatform = _resolvePluginImplementations(
|
||||||
|
plugins,
|
||||||
|
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
||||||
|
);
|
||||||
|
if (iosPlatform) {
|
||||||
|
await _writeIOSPluginRegistrant(project, pluginsByPlatform[IOSPlugin.kConfigKey]!);
|
||||||
|
}
|
||||||
|
if (macOSPlatform) {
|
||||||
|
await _writeMacOSPluginRegistrant(project, pluginsByPlatform[MacOSPlugin.kConfigKey]!);
|
||||||
|
}
|
||||||
final DarwinDependencyManagement darwinDependencyManagerSetup =
|
final DarwinDependencyManagement darwinDependencyManagerSetup =
|
||||||
darwinDependencyManagement ??
|
darwinDependencyManagement ??
|
||||||
DarwinDependencyManagement(
|
DarwinDependencyManagement(
|
||||||
|
@ -2649,7 +2649,7 @@ flutter:
|
|||||||
);
|
);
|
||||||
|
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
'excludes dev dependencies from iOS plugin registrant',
|
'includes dev dependencies from iOS plugin registrant',
|
||||||
() async {
|
() async {
|
||||||
createPlugin(
|
createPlugin(
|
||||||
name: testPluginName,
|
name: testPluginName,
|
||||||
@ -2682,7 +2682,7 @@ flutter:
|
|||||||
releaseMode: true,
|
releaseMode: true,
|
||||||
);
|
);
|
||||||
expect(generatedPluginRegistrantImpl, exists);
|
expect(generatedPluginRegistrantImpl, exists);
|
||||||
expect(generatedPluginRegistrantImpl.readAsStringSync(), isNot(contains(devDepImport)));
|
expect(generatedPluginRegistrantImpl.readAsStringSync(), contains(devDepImport));
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
@ -2729,7 +2729,7 @@ flutter:
|
|||||||
);
|
);
|
||||||
|
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
'excludes dev dependencies from MacOS plugin registrant',
|
'includes dev dependencies from MacOS plugin registrant',
|
||||||
() async {
|
() async {
|
||||||
createPlugin(
|
createPlugin(
|
||||||
name: testPluginName,
|
name: testPluginName,
|
||||||
@ -2767,7 +2767,7 @@ flutter:
|
|||||||
expect(generatedPluginRegistrant, exists);
|
expect(generatedPluginRegistrant, exists);
|
||||||
expect(
|
expect(
|
||||||
generatedPluginRegistrant.readAsStringSync(),
|
generatedPluginRegistrant.readAsStringSync(),
|
||||||
isNot(contains(expectedDevDepRegistration)),
|
contains(expectedDevDepRegistration),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user