mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Disable warnings for the dart plugin registrant (#76561)
This commit is contained in:
parent
b5139515c1
commit
098ece522d
@ -250,6 +250,8 @@ class KernelCompiler {
|
|||||||
mainUri,
|
mainUri,
|
||||||
newMainDart,
|
newMainDart,
|
||||||
mainFile,
|
mainFile,
|
||||||
|
// TODO(egarciad): Turn this on when the plugins are fixed.
|
||||||
|
throwOnPluginPubspecError: false,
|
||||||
)) {
|
)) {
|
||||||
mainUri = newMainDart.path;
|
mainUri = newMainDart.path;
|
||||||
}
|
}
|
||||||
|
@ -539,6 +539,7 @@ List<PluginInterfaceResolution> resolvePlatformImplementation(
|
|||||||
if (plugin.implementsPackage == null || plugin.implementsPackage.isEmpty) {
|
if (plugin.implementsPackage == null || plugin.implementsPackage.isEmpty) {
|
||||||
final String defaultImplementation = plugin.defaultPackagePlatforms[platform];
|
final String defaultImplementation = plugin.defaultPackagePlatforms[platform];
|
||||||
if (defaultImplementation == null) {
|
if (defaultImplementation == null) {
|
||||||
|
if (throwOnPluginPubspecError) {
|
||||||
globals.printError(
|
globals.printError(
|
||||||
'Plugin `${plugin.name}` doesn\'t implement a plugin interface, nor sets '
|
'Plugin `${plugin.name}` doesn\'t implement a plugin interface, nor sets '
|
||||||
'a default implementation in pubspec.yaml.\n\n'
|
'a default implementation in pubspec.yaml.\n\n'
|
||||||
@ -555,6 +556,7 @@ List<PluginInterfaceResolution> resolvePlatformImplementation(
|
|||||||
' implements: <plugin-interface>'
|
' implements: <plugin-interface>'
|
||||||
'\n'
|
'\n'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
didFindError = true;
|
didFindError = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -569,12 +571,14 @@ List<PluginInterfaceResolution> resolvePlatformImplementation(
|
|||||||
if (directDependencyResolutions.containsKey(resolutionKey)) {
|
if (directDependencyResolutions.containsKey(resolutionKey)) {
|
||||||
final PluginInterfaceResolution currResolution = directDependencyResolutions[resolutionKey];
|
final PluginInterfaceResolution currResolution = directDependencyResolutions[resolutionKey];
|
||||||
if (currResolution.plugin.isDirectDependency && plugin.isDirectDependency) {
|
if (currResolution.plugin.isDirectDependency && plugin.isDirectDependency) {
|
||||||
|
if (throwOnPluginPubspecError) {
|
||||||
globals.printError(
|
globals.printError(
|
||||||
'Plugin `${plugin.name}` implements an interface for `$platform`, which was already '
|
'Plugin `${plugin.name}` implements an interface for `$platform`, which was already '
|
||||||
'implemented by plugin `${currResolution.plugin.name}`.\n'
|
'implemented by plugin `${currResolution.plugin.name}`.\n'
|
||||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
'To fix this issue, remove either dependency from pubspec.yaml.'
|
||||||
'\n\n'
|
'\n\n'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
didFindError = true;
|
didFindError = true;
|
||||||
}
|
}
|
||||||
if (currResolution.plugin.isDirectDependency) {
|
if (currResolution.plugin.isDirectDependency) {
|
||||||
@ -931,19 +935,22 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
|
|||||||
/// Returns [true] if it's necessary to create a plugin registrant, and
|
/// Returns [true] if it's necessary to create a plugin registrant, and
|
||||||
/// if the new entrypoint was written to disk.
|
/// if the new entrypoint was written to disk.
|
||||||
///
|
///
|
||||||
|
/// This method also validates each plugin's pubspec.yaml, but errors are only
|
||||||
|
/// reported if [throwOnPluginPubspecError] is [true].
|
||||||
|
///
|
||||||
/// For more details, see https://flutter.dev/go/federated-plugins.
|
/// For more details, see https://flutter.dev/go/federated-plugins.
|
||||||
Future<bool> generateMainDartWithPluginRegistrant(
|
Future<bool> generateMainDartWithPluginRegistrant(
|
||||||
FlutterProject rootProject,
|
FlutterProject rootProject,
|
||||||
PackageConfig packageConfig,
|
PackageConfig packageConfig,
|
||||||
String currentMainUri,
|
String currentMainUri,
|
||||||
File newMainDart,
|
File newMainDart,
|
||||||
File mainFile,
|
File mainFile, {
|
||||||
) async {
|
bool throwOnPluginPubspecError,
|
||||||
|
}) async {
|
||||||
final List<Plugin> plugins = await findPlugins(rootProject);
|
final List<Plugin> plugins = await findPlugins(rootProject);
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(
|
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(
|
||||||
plugins,
|
plugins,
|
||||||
// TODO(egarciad): Turn this on after fixing the pubspec.yaml of the plugins used in tests.
|
throwOnPluginPubspecError: throwOnPluginPubspecError,
|
||||||
throwOnPluginPubspecError: false,
|
|
||||||
);
|
);
|
||||||
final LanguageVersion entrypointVersion = determineLanguageVersion(
|
final LanguageVersion entrypointVersion = determineLanguageVersion(
|
||||||
mainFile,
|
mainFile,
|
||||||
|
@ -1915,6 +1915,7 @@ void main() {
|
|||||||
'package:app/main.dart',
|
'package:app/main.dart',
|
||||||
flutterBuild,
|
flutterBuild,
|
||||||
mainFile,
|
mainFile,
|
||||||
|
throwOnPluginPubspecError: true,
|
||||||
);
|
);
|
||||||
expect(didGenerate, isTrue);
|
expect(didGenerate, isTrue);
|
||||||
expect(flutterBuild.readAsStringSync(),
|
expect(flutterBuild.readAsStringSync(),
|
||||||
@ -2000,6 +2001,7 @@ void main() {
|
|||||||
'package:app/main.dart',
|
'package:app/main.dart',
|
||||||
flutterBuild,
|
flutterBuild,
|
||||||
mainFile,
|
mainFile,
|
||||||
|
throwOnPluginPubspecError: true,
|
||||||
), throwsToolExit(message:
|
), throwsToolExit(message:
|
||||||
'Invalid plugin specification url_launcher_macos.\n'
|
'Invalid plugin specification url_launcher_macos.\n'
|
||||||
'Invalid "macos" plugin specification.'
|
'Invalid "macos" plugin specification.'
|
||||||
@ -2055,6 +2057,7 @@ void main() {
|
|||||||
'package:app/main.dart',
|
'package:app/main.dart',
|
||||||
flutterBuild,
|
flutterBuild,
|
||||||
mainFile,
|
mainFile,
|
||||||
|
throwOnPluginPubspecError: true,
|
||||||
), throwsToolExit(message:
|
), throwsToolExit(message:
|
||||||
'Invalid plugin specification url_launcher_macos.\n'
|
'Invalid plugin specification url_launcher_macos.\n'
|
||||||
'Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. '
|
'Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. '
|
||||||
@ -2066,6 +2069,35 @@ void main() {
|
|||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('Does not show error messages if throwOnPluginPubspecError is false', () async {
|
||||||
|
final FileSystem fs = MemoryFileSystem();
|
||||||
|
final Set<String> directDependencies = <String>{
|
||||||
|
'url_launcher_windows',
|
||||||
|
};
|
||||||
|
resolvePlatformImplementation(<Plugin>[
|
||||||
|
Plugin.fromYaml(
|
||||||
|
'url_launcher_windows',
|
||||||
|
'',
|
||||||
|
YamlMap.wrap(<String, dynamic>{
|
||||||
|
'platforms': <String, dynamic>{
|
||||||
|
'windows': <String, dynamic>{
|
||||||
|
'dartPluginClass': 'UrlLauncherPluginWindows',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
<String>[],
|
||||||
|
fileSystem: fs,
|
||||||
|
appDependencies: directDependencies,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
throwOnPluginPubspecError: false,
|
||||||
|
);
|
||||||
|
expect(testLogger.errorText, '');
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('pubspec', () {
|
group('pubspec', () {
|
||||||
|
Loading…
Reference in New Issue
Block a user