forked from firka/flutter
Removes dev dependencies from generated plugin registrant for non-Android platforms (#161828)
Removes dev dependencies from the generated plugin registrants for all platforms since they will be removed from release builds (this was already done for Android, mostly in https://github.com/flutter/flutter/pull/161343). Fixes https://github.com/flutter/flutter/issues/161348. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
@@ -363,20 +363,11 @@ List<Map<String, Object?>> _extractPlatformMaps(Iterable<Plugin> plugins, String
|
||||
];
|
||||
}
|
||||
|
||||
Future<void> _writeAndroidPluginRegistrant(
|
||||
FlutterProject project,
|
||||
List<Plugin> plugins, {
|
||||
required bool releaseMode,
|
||||
}) async {
|
||||
Iterable<Plugin> methodChannelPlugins = _filterMethodChannelPlugins(
|
||||
Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin> plugins) async {
|
||||
final List<Plugin> methodChannelPlugins = _filterMethodChannelPlugins(
|
||||
plugins,
|
||||
AndroidPlugin.kConfigKey,
|
||||
);
|
||||
// TODO(camsim99): Remove dev dependencies from release builds for all platforms. See https://github.com/flutter/flutter/issues/161348.
|
||||
if (releaseMode) {
|
||||
methodChannelPlugins = methodChannelPlugins.where((Plugin p) => !p.isDevDependency);
|
||||
}
|
||||
|
||||
final List<Map<String, Object?>> androidPlugins = _extractPlatformMaps(
|
||||
methodChannelPlugins,
|
||||
AndroidPlugin.kConfigKey,
|
||||
@@ -1204,7 +1195,7 @@ Future<void> injectBuildTimePluginFilesForWebPlatform(
|
||||
|
||||
/// Injects plugins found in `pubspec.yaml` into the platform-specific projects.
|
||||
///
|
||||
/// The injected files are required by the flutter app as soon as possible, so
|
||||
/// The injected files are required by the Flutter app as soon as possible, so
|
||||
/// it can be built.
|
||||
///
|
||||
/// Files written by this method end up in platform-specific locations that are
|
||||
@@ -1225,18 +1216,19 @@ Future<void> injectPlugins(
|
||||
DarwinDependencyManagement? darwinDependencyManagement,
|
||||
bool? releaseMode,
|
||||
}) async {
|
||||
final List<Plugin> plugins = await findPlugins(project);
|
||||
List<Plugin> plugins = await findPlugins(project);
|
||||
|
||||
if (releaseMode ?? false) {
|
||||
plugins = plugins.where((Plugin p) => !p.isDevDependency).toList();
|
||||
}
|
||||
|
||||
final Map<String, List<Plugin>> pluginsByPlatform = _resolvePluginImplementations(
|
||||
plugins,
|
||||
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
||||
);
|
||||
|
||||
if (androidPlatform) {
|
||||
await _writeAndroidPluginRegistrant(
|
||||
project,
|
||||
pluginsByPlatform[AndroidPlugin.kConfigKey]!,
|
||||
releaseMode: releaseMode ?? false,
|
||||
);
|
||||
await _writeAndroidPluginRegistrant(project, pluginsByPlatform[AndroidPlugin.kConfigKey]!);
|
||||
}
|
||||
if (iosPlatform) {
|
||||
await _writeIOSPluginRegistrant(project, pluginsByPlatform[IOSPlugin.kConfigKey]!);
|
||||
|
||||
@@ -244,7 +244,7 @@ class AndroidPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
||||
/// The [name] of the plugin is required. Additionally, either:
|
||||
/// - [defaultPackage], or
|
||||
/// - an implementation consisting of:
|
||||
/// - the [pluginClass] (with optional [classPrefix]) that will be the entry
|
||||
/// - the [classPrefix] (with optional [pluginClass]) that will be the entry
|
||||
/// point to the plugin's native code, and/or
|
||||
/// - the [dartPluginClass] with optional [dartFileName] that will be
|
||||
/// the entry point for the plugin's Dart code
|
||||
|
||||
@@ -637,6 +637,18 @@ class AndroidProject extends FlutterProjectPlatform {
|
||||
return hostAppGradleRoot.childFile('AndroidManifest.xml');
|
||||
}
|
||||
|
||||
File get generatedPluginRegistrantFile {
|
||||
return hostAppGradleRoot
|
||||
.childDirectory('app')
|
||||
.childDirectory('src')
|
||||
.childDirectory('main')
|
||||
.childDirectory('java')
|
||||
.childDirectory('io')
|
||||
.childDirectory('flutter')
|
||||
.childDirectory('plugins')
|
||||
.childFile('GeneratedPluginRegistrant.java');
|
||||
}
|
||||
|
||||
File get gradleAppOutV1File => gradleAppOutV1Directory.childFile('app-debug.apk');
|
||||
|
||||
Directory get gradleAppOutV1Directory {
|
||||
|
||||
Reference in New Issue
Block a user