* Revert "Enable dart_plugin_registry_test (#76645)" This reverts commit 109e0bb9f55ed6e9884547843356d16897eaf6a9. * Revert "Apply changes caused by https://github.com/flutter/flutter/pull/76662 (#77093)" This reverts commit cdca6485f05287bb12b1acebbbae2ba107d6c1be. * Revert "Disable clang format in the plugin registrants (#76662)" This reverts commit dadbd47d097f5cce868832fa8b4d03439a5c8402. * Revert "Disable warnings for the dart plugin registrant (#76561)" This reverts commit 098ece522d41f25370d19f5ec09d93ce2e727019. * Revert "Remove dart_plugin_registry_test timeouts (#76838)" This reverts commit 1610a2747654dec3cabbd1d81d0bc5885b2067a2. * Revert "Implement dartPluginClass support for plugins (#74469)" This reverts commit b7d4806243a4e906bf061f79a0e314ba28111aa6. Kick.
This commit is contained in:
parent
46c99809b4
commit
5efc7169eb
@ -1,10 +0,0 @@
|
|||||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'package:flutter_devicelab/tasks/dart_plugin_registry_tests.dart';
|
|
||||||
import 'package:flutter_devicelab/framework/framework.dart';
|
|
||||||
|
|
||||||
Future<void> main() async {
|
|
||||||
await task(dartPluginRegistryTest());
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
import 'package:flutter_devicelab/framework/framework.dart';
|
|
||||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
|
||||||
import 'package:flutter_devicelab/framework/utils.dart';
|
|
||||||
|
|
||||||
TaskFunction dartPluginRegistryTest({
|
|
||||||
String deviceIdOverride,
|
|
||||||
Map<String, String> environment,
|
|
||||||
}) {
|
|
||||||
final Directory tempDir = Directory.systemTemp
|
|
||||||
.createTempSync('flutter_devicelab_dart_plugin_test.');
|
|
||||||
return () async {
|
|
||||||
try {
|
|
||||||
section('Create implementation plugin');
|
|
||||||
await inDirectory(tempDir, () async {
|
|
||||||
await flutter(
|
|
||||||
'create',
|
|
||||||
options: <String>[
|
|
||||||
'--template=plugin',
|
|
||||||
'--org',
|
|
||||||
'io.flutter.devicelab',
|
|
||||||
'--platforms',
|
|
||||||
'macos',
|
|
||||||
'plugin_platform_implementation',
|
|
||||||
],
|
|
||||||
environment: environment,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
final File pluginMain = File(path.join(
|
|
||||||
tempDir.absolute.path,
|
|
||||||
'plugin_platform_implementation',
|
|
||||||
'lib',
|
|
||||||
'plugin_platform_implementation.dart',
|
|
||||||
));
|
|
||||||
if (!pluginMain.existsSync()) {
|
|
||||||
return TaskResult.failure('${pluginMain.path} does not exist');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Patch plugin main dart file.
|
|
||||||
await pluginMain.writeAsString('''
|
|
||||||
class PluginPlatformInterfaceMacOS {
|
|
||||||
static void registerWith() {
|
|
||||||
print('PluginPlatformInterfaceMacOS.registerWith() was called');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
''', flush: true);
|
|
||||||
|
|
||||||
// Patch plugin main pubspec file.
|
|
||||||
final File pluginImplPubspec = File(path.join(
|
|
||||||
tempDir.absolute.path,
|
|
||||||
'plugin_platform_implementation',
|
|
||||||
'pubspec.yaml',
|
|
||||||
));
|
|
||||||
String pluginImplPubspecContent = await pluginImplPubspec.readAsString();
|
|
||||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
|
||||||
' pluginClass: PluginPlatformImplementationPlugin',
|
|
||||||
' pluginClass: PluginPlatformImplementationPlugin\n'
|
|
||||||
' dartPluginClass: PluginPlatformInterfaceMacOS\n',
|
|
||||||
);
|
|
||||||
pluginImplPubspecContent = pluginImplPubspecContent.replaceFirst(
|
|
||||||
' platforms:\n',
|
|
||||||
' implements: plugin_platform_interface\n'
|
|
||||||
' platforms:\n');
|
|
||||||
await pluginImplPubspec.writeAsString(pluginImplPubspecContent,
|
|
||||||
flush: true);
|
|
||||||
|
|
||||||
section('Create interface plugin');
|
|
||||||
await inDirectory(tempDir, () async {
|
|
||||||
await flutter(
|
|
||||||
'create',
|
|
||||||
options: <String>[
|
|
||||||
'--template=plugin',
|
|
||||||
'--org',
|
|
||||||
'io.flutter.devicelab',
|
|
||||||
'--platforms',
|
|
||||||
'macos',
|
|
||||||
'plugin_platform_interface',
|
|
||||||
],
|
|
||||||
environment: environment,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
final File pluginInterfacePubspec = File(path.join(
|
|
||||||
tempDir.absolute.path,
|
|
||||||
'plugin_platform_interface',
|
|
||||||
'pubspec.yaml',
|
|
||||||
));
|
|
||||||
String pluginInterfacePubspecContent =
|
|
||||||
await pluginInterfacePubspec.readAsString();
|
|
||||||
pluginInterfacePubspecContent =
|
|
||||||
pluginInterfacePubspecContent.replaceFirst(
|
|
||||||
' pluginClass: PluginPlatformInterfacePlugin',
|
|
||||||
' default_package: plugin_platform_implementation\n');
|
|
||||||
pluginInterfacePubspecContent =
|
|
||||||
pluginInterfacePubspecContent.replaceFirst(
|
|
||||||
'dependencies:',
|
|
||||||
'dependencies:\n'
|
|
||||||
' plugin_platform_implementation:\n'
|
|
||||||
' path: ../plugin_platform_implementation\n');
|
|
||||||
await pluginInterfacePubspec.writeAsString(pluginInterfacePubspecContent,
|
|
||||||
flush: true);
|
|
||||||
|
|
||||||
section('Create app');
|
|
||||||
|
|
||||||
await inDirectory(tempDir, () async {
|
|
||||||
await flutter(
|
|
||||||
'create',
|
|
||||||
options: <String>[
|
|
||||||
'--template=app',
|
|
||||||
'--org',
|
|
||||||
'io.flutter.devicelab',
|
|
||||||
'--platforms',
|
|
||||||
'macos',
|
|
||||||
'app',
|
|
||||||
],
|
|
||||||
environment: environment,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
final File appPubspec = File(path.join(
|
|
||||||
tempDir.absolute.path,
|
|
||||||
'app',
|
|
||||||
'pubspec.yaml',
|
|
||||||
));
|
|
||||||
String appPubspecContent = await appPubspec.readAsString();
|
|
||||||
appPubspecContent = appPubspecContent.replaceFirst(
|
|
||||||
'dependencies:',
|
|
||||||
'dependencies:\n'
|
|
||||||
' plugin_platform_interface:\n'
|
|
||||||
' path: ../plugin_platform_interface\n');
|
|
||||||
await appPubspec.writeAsString(appPubspecContent, flush: true);
|
|
||||||
|
|
||||||
section('Flutter run for macos');
|
|
||||||
|
|
||||||
await inDirectory(path.join(tempDir.path, 'app'), () async {
|
|
||||||
final Process run = await startProcess(
|
|
||||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
|
||||||
flutterCommandArgs('run', <String>['-d', 'macos', '-v']),
|
|
||||||
environment: null,
|
|
||||||
);
|
|
||||||
Completer<void> registryExecutedCompleter = Completer<void>();
|
|
||||||
final StreamSubscription<void> subscription = run.stdout
|
|
||||||
.transform<String>(utf8.decoder)
|
|
||||||
.transform<String>(const LineSplitter())
|
|
||||||
.listen((String line) {
|
|
||||||
if (line.contains(
|
|
||||||
'PluginPlatformInterfaceMacOS.registerWith() was called')) {
|
|
||||||
registryExecutedCompleter.complete();
|
|
||||||
}
|
|
||||||
print('stdout: $line');
|
|
||||||
});
|
|
||||||
|
|
||||||
section('Wait for registry execution');
|
|
||||||
await registryExecutedCompleter.future;
|
|
||||||
|
|
||||||
// Hot restart.
|
|
||||||
run.stdin.write('R');
|
|
||||||
registryExecutedCompleter = Completer<void>();
|
|
||||||
|
|
||||||
section('Wait for registry execution after hot restart');
|
|
||||||
await registryExecutedCompleter.future;
|
|
||||||
|
|
||||||
subscription.cancel();
|
|
||||||
run.kill();
|
|
||||||
});
|
|
||||||
return TaskResult.success(null);
|
|
||||||
} finally {
|
|
||||||
rmTree(tempDir);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||||
#define GENERATED_PLUGIN_REGISTRANT_
|
#define GENERATED_PLUGIN_REGISTRANT_
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <url_launcher_windows/url_launcher_plugin.h>
|
#include <url_launcher_windows/url_launcher_plugin.h>
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||||
#define GENERATED_PLUGIN_REGISTRANT_
|
#define GENERATED_PLUGIN_REGISTRANT_
|
||||||
|
|
||||||
|
@ -904,7 +904,7 @@
|
|||||||
"name": "Mac dart_plugin_registry_test",
|
"name": "Mac dart_plugin_registry_test",
|
||||||
"repo": "flutter",
|
"repo": "flutter",
|
||||||
"task_name": "dart_plugin_registry_test",
|
"task_name": "dart_plugin_registry_test",
|
||||||
"flaky": false
|
"flaky": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Mac tool_tests_general",
|
"name": "Mac tool_tests_general",
|
||||||
|
@ -536,7 +536,7 @@
|
|||||||
"name": "Mac dart_plugin_registry_test",
|
"name": "Mac dart_plugin_registry_test",
|
||||||
"repo": "flutter",
|
"repo": "flutter",
|
||||||
"task_name": "dart_plugin_registry_test",
|
"task_name": "dart_plugin_registry_test",
|
||||||
"enabled": true,
|
"enabled": false,
|
||||||
"run_if": ["dev/**", "packages/flutter_tools/**", "bin/**"]
|
"run_if": ["dev/**", "packages/flutter_tools/**", "bin/**"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GeneratedPluginRegistrant_h
|
#ifndef GeneratedPluginRegistrant_h
|
||||||
#define GeneratedPluginRegistrant_h
|
#define GeneratedPluginRegistrant_h
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#import "GeneratedPluginRegistrant.h"
|
#import "GeneratedPluginRegistrant.h"
|
||||||
|
|
||||||
@implementation GeneratedPluginRegistrant
|
@implementation GeneratedPluginRegistrant
|
||||||
|
@ -331,7 +331,6 @@ class Environment {
|
|||||||
@required Artifacts artifacts,
|
@required Artifacts artifacts,
|
||||||
@required ProcessManager processManager,
|
@required ProcessManager processManager,
|
||||||
@required String engineVersion,
|
@required String engineVersion,
|
||||||
@required bool generateDartPluginRegistry,
|
|
||||||
Directory buildDir,
|
Directory buildDir,
|
||||||
Map<String, String> defines = const <String, String>{},
|
Map<String, String> defines = const <String, String>{},
|
||||||
Map<String, String> inputs = const <String, String>{},
|
Map<String, String> inputs = const <String, String>{},
|
||||||
@ -371,7 +370,6 @@ class Environment {
|
|||||||
processManager: processManager,
|
processManager: processManager,
|
||||||
engineVersion: engineVersion,
|
engineVersion: engineVersion,
|
||||||
inputs: inputs,
|
inputs: inputs,
|
||||||
generateDartPluginRegistry: generateDartPluginRegistry,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,7 +386,6 @@ class Environment {
|
|||||||
Map<String, String> defines = const <String, String>{},
|
Map<String, String> defines = const <String, String>{},
|
||||||
Map<String, String> inputs = const <String, String>{},
|
Map<String, String> inputs = const <String, String>{},
|
||||||
String engineVersion,
|
String engineVersion,
|
||||||
bool generateDartPluginRegistry = false,
|
|
||||||
@required FileSystem fileSystem,
|
@required FileSystem fileSystem,
|
||||||
@required Logger logger,
|
@required Logger logger,
|
||||||
@required Artifacts artifacts,
|
@required Artifacts artifacts,
|
||||||
@ -407,7 +404,6 @@ class Environment {
|
|||||||
artifacts: artifacts,
|
artifacts: artifacts,
|
||||||
processManager: processManager,
|
processManager: processManager,
|
||||||
engineVersion: engineVersion,
|
engineVersion: engineVersion,
|
||||||
generateDartPluginRegistry: generateDartPluginRegistry,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +421,6 @@ class Environment {
|
|||||||
@required this.artifacts,
|
@required this.artifacts,
|
||||||
@required this.engineVersion,
|
@required this.engineVersion,
|
||||||
@required this.inputs,
|
@required this.inputs,
|
||||||
@required this.generateDartPluginRegistry,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The [Source] value which is substituted with the path to [projectDir].
|
/// The [Source] value which is substituted with the path to [projectDir].
|
||||||
@ -503,11 +498,6 @@ class Environment {
|
|||||||
|
|
||||||
/// The version of the current engine, or `null` if built with a local engine.
|
/// The version of the current engine, or `null` if built with a local engine.
|
||||||
final String engineVersion;
|
final String engineVersion;
|
||||||
|
|
||||||
/// Whether to generate the Dart plugin registry.
|
|
||||||
/// When [true], the main entrypoint is wrapped and the wrapper becomes
|
|
||||||
/// the new entrypoint.
|
|
||||||
final bool generateDartPluginRegistry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result information from the build system.
|
/// The result information from the build system.
|
||||||
|
@ -286,8 +286,6 @@ class KernelSnapshot extends Target {
|
|||||||
fileSystemScheme: fileSystemScheme,
|
fileSystemScheme: fileSystemScheme,
|
||||||
dartDefines: decodeDartDefines(environment.defines, kDartDefines),
|
dartDefines: decodeDartDefines(environment.defines, kDartDefines),
|
||||||
packageConfig: packageConfig,
|
packageConfig: packageConfig,
|
||||||
buildDir: environment.buildDir,
|
|
||||||
generateDartPluginRegistry: environment.generateDartPluginRegistry,
|
|
||||||
);
|
);
|
||||||
if (output == null || output.errorCount != 0) {
|
if (output == null || output.errorCount != 0) {
|
||||||
throw Exception();
|
throw Exception();
|
||||||
|
@ -160,7 +160,6 @@ Future<void> buildWithAssemble({
|
|||||||
fileSystem: globals.fs,
|
fileSystem: globals.fs,
|
||||||
logger: globals.logger,
|
logger: globals.logger,
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
final Target target = buildMode == BuildMode.debug
|
final Target target = buildMode == BuildMode.debug
|
||||||
? const CopyFlutterBundle()
|
? const CopyFlutterBundle()
|
||||||
|
@ -241,8 +241,7 @@ class AssembleCommand extends FlutterCommand {
|
|||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
engineVersion: globals.artifacts.isLocalEngine
|
engineVersion: globals.artifacts.isLocalEngine
|
||||||
? null
|
? null
|
||||||
: globals.flutterVersion.engineRevision,
|
: globals.flutterVersion.engineRevision
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,6 @@ end
|
|||||||
engineVersion: globals.artifacts.isLocalEngine
|
engineVersion: globals.artifacts.isLocalEngine
|
||||||
? null
|
? null
|
||||||
: globals.flutterVersion.engineRevision,
|
: globals.flutterVersion.engineRevision,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
Target target;
|
Target target;
|
||||||
// Always build debug for simulator.
|
// Always build debug for simulator.
|
||||||
|
@ -119,7 +119,6 @@ class PackagesGetCommand extends FlutterCommand {
|
|||||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
outputDir: globals.fs.directory(getBuildDirectory()),
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
projectDir: flutterProject.directory,
|
projectDir: flutterProject.directory,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await generateLocalizationsSyntheticPackage(
|
await generateLocalizationsSyntheticPackage(
|
||||||
@ -325,7 +324,6 @@ class PackagesInteractiveGetCommand extends FlutterCommand {
|
|||||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
outputDir: globals.fs.directory(getBuildDirectory()),
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
projectDir: flutterProject.directory,
|
projectDir: flutterProject.directory,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await generateLocalizationsSyntheticPackage(
|
await generateLocalizationsSyntheticPackage(
|
||||||
|
@ -20,8 +20,6 @@ import 'base/logger.dart';
|
|||||||
import 'base/platform.dart';
|
import 'base/platform.dart';
|
||||||
import 'build_info.dart';
|
import 'build_info.dart';
|
||||||
import 'convert.dart';
|
import 'convert.dart';
|
||||||
import 'plugins.dart';
|
|
||||||
import 'project.dart';
|
|
||||||
|
|
||||||
/// The target model describes the set of core libraries that are available within
|
/// The target model describes the set of core libraries that are available within
|
||||||
/// the SDK.
|
/// the SDK.
|
||||||
@ -231,8 +229,6 @@ class KernelCompiler {
|
|||||||
String fileSystemScheme,
|
String fileSystemScheme,
|
||||||
String initializeFromDill,
|
String initializeFromDill,
|
||||||
String platformDill,
|
String platformDill,
|
||||||
Directory buildDir,
|
|
||||||
bool generateDartPluginRegistry = false,
|
|
||||||
@required String packagesPath,
|
@required String packagesPath,
|
||||||
@required BuildMode buildMode,
|
@required BuildMode buildMode,
|
||||||
@required bool trackWidgetCreation,
|
@required bool trackWidgetCreation,
|
||||||
@ -251,8 +247,7 @@ class KernelCompiler {
|
|||||||
throwToolExit('Unable to find Dart binary at $engineDartPath');
|
throwToolExit('Unable to find Dart binary at $engineDartPath');
|
||||||
}
|
}
|
||||||
String mainUri;
|
String mainUri;
|
||||||
final File mainFile = _fileSystem.file(mainPath);
|
final Uri mainFileUri = _fileSystem.file(mainPath).uri;
|
||||||
final Uri mainFileUri = mainFile.uri;
|
|
||||||
if (packagesPath != null) {
|
if (packagesPath != null) {
|
||||||
mainUri = packageConfig.toPackageUri(mainFileUri)?.toString();
|
mainUri = packageConfig.toPackageUri(mainFileUri)?.toString();
|
||||||
}
|
}
|
||||||
@ -260,23 +255,6 @@ class KernelCompiler {
|
|||||||
if (outputFilePath != null && !_fileSystem.isFileSync(outputFilePath)) {
|
if (outputFilePath != null && !_fileSystem.isFileSync(outputFilePath)) {
|
||||||
_fileSystem.file(outputFilePath).createSync(recursive: true);
|
_fileSystem.file(outputFilePath).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
if (buildDir != null && generateDartPluginRegistry) {
|
|
||||||
// `generated_main.dart` is under `.dart_tools/flutter_build/`,
|
|
||||||
// so the resident compiler can find it.
|
|
||||||
final File newMainDart = buildDir.parent.childFile('generated_main.dart');
|
|
||||||
if (await generateMainDartWithPluginRegistrant(
|
|
||||||
FlutterProject.current(),
|
|
||||||
packageConfig,
|
|
||||||
mainUri,
|
|
||||||
newMainDart,
|
|
||||||
mainFile,
|
|
||||||
// TODO(egarciad): Turn this on when the plugins are fixed.
|
|
||||||
throwOnPluginPubspecError: false,
|
|
||||||
)) {
|
|
||||||
mainUri = newMainDart.path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
engineDartPath,
|
engineDartPath,
|
||||||
'--disable-dart-dev',
|
'--disable-dart-dev',
|
||||||
@ -623,6 +601,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
if (!_controller.hasListener) {
|
if (!_controller.hasListener) {
|
||||||
_controller.stream.listen(_handleCompilationRequest);
|
_controller.stream.listen(_handleCompilationRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Completer<CompilerOutput> completer = Completer<CompilerOutput>();
|
final Completer<CompilerOutput> completer = Completer<CompilerOutput>();
|
||||||
_controller.add(
|
_controller.add(
|
||||||
_RecompileRequest(completer, mainUri, invalidatedFiles, outputPath, packageConfig, suppressErrors)
|
_RecompileRequest(completer, mainUri, invalidatedFiles, outputPath, packageConfig, suppressErrors)
|
||||||
|
@ -518,20 +518,6 @@ class DevFS {
|
|||||||
// dill files that depend on the invalidated files.
|
// dill files that depend on the invalidated files.
|
||||||
_logger.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
|
_logger.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
|
||||||
|
|
||||||
// `generated_main.dart` contains the Dart plugin registry.
|
|
||||||
if (projectRootPath != null) {
|
|
||||||
final File generatedMainDart = _fileSystem.file(
|
|
||||||
_fileSystem.path.join(
|
|
||||||
projectRootPath,
|
|
||||||
'.dart_tool',
|
|
||||||
'flutter_build',
|
|
||||||
'generated_main.dart',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (generatedMainDart != null && generatedMainDart.existsSync()) {
|
|
||||||
mainUri = generatedMainDart.uri;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Await the compiler response after checking if the bundle is updated. This allows the file
|
// Await the compiler response after checking if the bundle is updated. This allows the file
|
||||||
// stating to be done while waiting for the frontend_server response.
|
// stating to be done while waiting for the frontend_server response.
|
||||||
final Future<CompilerOutput> pendingCompilerOutput = generator.recompile(
|
final Future<CompilerOutput> pendingCompilerOutput = generator.recompile(
|
||||||
|
@ -86,13 +86,6 @@ class FlutterManifest {
|
|||||||
/// The string value of the top-level `name` property in the `pubspec.yaml` file.
|
/// The string value of the top-level `name` property in the `pubspec.yaml` file.
|
||||||
String get appName => _descriptor['name'] as String ?? '';
|
String get appName => _descriptor['name'] as String ?? '';
|
||||||
|
|
||||||
/// Contains the name of the dependencies.
|
|
||||||
/// These are the keys specified in the `dependency` map.
|
|
||||||
Set<String> get dependencies {
|
|
||||||
final YamlMap dependencies = _descriptor['dependencies'] as YamlMap;
|
|
||||||
return dependencies != null ? <String>{...dependencies.keys.cast<String>()} : <String>{};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Flag to avoid printing multiple invalid version messages.
|
// Flag to avoid printing multiple invalid version messages.
|
||||||
bool _hasShowInvalidVersionMsg = false;
|
bool _hasShowInvalidVersionMsg = false;
|
||||||
|
|
||||||
|
@ -16,9 +16,6 @@ const String kPluginClass = 'pluginClass';
|
|||||||
/// Constant for 'pluginClass' key in plugin maps.
|
/// Constant for 'pluginClass' key in plugin maps.
|
||||||
const String kDartPluginClass = 'dartPluginClass';
|
const String kDartPluginClass = 'dartPluginClass';
|
||||||
|
|
||||||
// Constant for 'defaultPackage' key in plugin maps.
|
|
||||||
const String kDefaultPackage = 'default_package';
|
|
||||||
|
|
||||||
/// Marker interface for all platform specific plugin config implementations.
|
/// Marker interface for all platform specific plugin config implementations.
|
||||||
abstract class PluginPlatform {
|
abstract class PluginPlatform {
|
||||||
const PluginPlatform();
|
const PluginPlatform();
|
||||||
@ -210,7 +207,6 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
@required this.name,
|
@required this.name,
|
||||||
this.pluginClass,
|
this.pluginClass,
|
||||||
this.dartPluginClass,
|
this.dartPluginClass,
|
||||||
this.defaultPackage,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory MacOSPlugin.fromYaml(String name, YamlMap yaml) {
|
factory MacOSPlugin.fromYaml(String name, YamlMap yaml) {
|
||||||
@ -224,7 +220,6 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
name: name,
|
name: name,
|
||||||
pluginClass: pluginClass,
|
pluginClass: pluginClass,
|
||||||
dartPluginClass: yaml[kDartPluginClass] as String,
|
dartPluginClass: yaml[kDartPluginClass] as String,
|
||||||
defaultPackage: yaml[kDefaultPackage] as String,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +227,7 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
if (yaml == null) {
|
if (yaml == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return yaml[kPluginClass] is String ||
|
return yaml[kPluginClass] is String || yaml[kDartPluginClass] is String;
|
||||||
yaml[kDartPluginClass] is String ||
|
|
||||||
yaml[kDefaultPackage] is String;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const String kConfigKey = 'macos';
|
static const String kConfigKey = 'macos';
|
||||||
@ -242,7 +235,6 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
final String name;
|
final String name;
|
||||||
final String pluginClass;
|
final String pluginClass;
|
||||||
final String dartPluginClass;
|
final String dartPluginClass;
|
||||||
final String defaultPackage;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isNative() => pluginClass != null;
|
bool isNative() => pluginClass != null;
|
||||||
@ -252,8 +244,7 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
'name': name,
|
'name': name,
|
||||||
if (pluginClass != null) 'class': pluginClass,
|
if (pluginClass != null) 'class': pluginClass,
|
||||||
if (dartPluginClass != null) kDartPluginClass : dartPluginClass,
|
if (dartPluginClass != null) 'dartPluginClass': dartPluginClass,
|
||||||
if (defaultPackage != null) kDefaultPackage : defaultPackage,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,8 +258,7 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
|
|||||||
@required this.name,
|
@required this.name,
|
||||||
this.pluginClass,
|
this.pluginClass,
|
||||||
this.dartPluginClass,
|
this.dartPluginClass,
|
||||||
this.defaultPackage,
|
}) : assert(pluginClass != null || dartPluginClass != null);
|
||||||
}) : assert(pluginClass != null || dartPluginClass != null || defaultPackage != null);
|
|
||||||
|
|
||||||
factory WindowsPlugin.fromYaml(String name, YamlMap yaml) {
|
factory WindowsPlugin.fromYaml(String name, YamlMap yaml) {
|
||||||
assert(validate(yaml));
|
assert(validate(yaml));
|
||||||
@ -281,7 +271,6 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
|
|||||||
name: name,
|
name: name,
|
||||||
pluginClass: pluginClass,
|
pluginClass: pluginClass,
|
||||||
dartPluginClass: yaml[kDartPluginClass] as String,
|
dartPluginClass: yaml[kDartPluginClass] as String,
|
||||||
defaultPackage: yaml[kDefaultPackage] as String,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,9 +278,7 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
|
|||||||
if (yaml == null) {
|
if (yaml == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return yaml[kPluginClass] is String ||
|
return yaml[kDartPluginClass] is String || yaml[kPluginClass] is String;
|
||||||
yaml[kDartPluginClass] is String ||
|
|
||||||
yaml[kDefaultPackage] is String;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const String kConfigKey = 'windows';
|
static const String kConfigKey = 'windows';
|
||||||
@ -299,7 +286,6 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
|
|||||||
final String name;
|
final String name;
|
||||||
final String pluginClass;
|
final String pluginClass;
|
||||||
final String dartPluginClass;
|
final String dartPluginClass;
|
||||||
final String defaultPackage;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isNative() => pluginClass != null;
|
bool isNative() => pluginClass != null;
|
||||||
@ -310,8 +296,7 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
|
|||||||
'name': name,
|
'name': name,
|
||||||
if (pluginClass != null) 'class': pluginClass,
|
if (pluginClass != null) 'class': pluginClass,
|
||||||
if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass),
|
if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass),
|
||||||
if (dartPluginClass != null) kDartPluginClass: dartPluginClass,
|
if (dartPluginClass != null) 'dartPluginClass': dartPluginClass,
|
||||||
if (defaultPackage != null) kDefaultPackage: defaultPackage,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,8 +310,7 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
@required this.name,
|
@required this.name,
|
||||||
this.pluginClass,
|
this.pluginClass,
|
||||||
this.dartPluginClass,
|
this.dartPluginClass,
|
||||||
this.defaultPackage,
|
}) : assert(pluginClass != null || dartPluginClass != null);
|
||||||
}) : assert(pluginClass != null || dartPluginClass != null || defaultPackage != null);
|
|
||||||
|
|
||||||
factory LinuxPlugin.fromYaml(String name, YamlMap yaml) {
|
factory LinuxPlugin.fromYaml(String name, YamlMap yaml) {
|
||||||
assert(validate(yaml));
|
assert(validate(yaml));
|
||||||
@ -339,7 +323,6 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
name: name,
|
name: name,
|
||||||
pluginClass: pluginClass,
|
pluginClass: pluginClass,
|
||||||
dartPluginClass: yaml[kDartPluginClass] as String,
|
dartPluginClass: yaml[kDartPluginClass] as String,
|
||||||
defaultPackage: yaml[kDefaultPackage] as String,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,9 +330,7 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
if (yaml == null) {
|
if (yaml == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return yaml[kPluginClass] is String ||
|
return yaml[kPluginClass] is String || yaml[kDartPluginClass] is String;
|
||||||
yaml[kDartPluginClass] is String ||
|
|
||||||
yaml[kDefaultPackage] is String;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const String kConfigKey = 'linux';
|
static const String kConfigKey = 'linux';
|
||||||
@ -357,7 +338,6 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
final String name;
|
final String name;
|
||||||
final String pluginClass;
|
final String pluginClass;
|
||||||
final String dartPluginClass;
|
final String dartPluginClass;
|
||||||
final String defaultPackage;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isNative() => pluginClass != null;
|
bool isNative() => pluginClass != null;
|
||||||
@ -368,8 +348,7 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
|
|||||||
'name': name,
|
'name': name,
|
||||||
if (pluginClass != null) 'class': pluginClass,
|
if (pluginClass != null) 'class': pluginClass,
|
||||||
if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass),
|
if (pluginClass != null) 'filename': _filenameForCppClass(pluginClass),
|
||||||
if (dartPluginClass != null) kDartPluginClass: dartPluginClass,
|
if (dartPluginClass != null) 'dartPluginClass': dartPluginClass,
|
||||||
if (defaultPackage != null) kDefaultPackage: defaultPackage,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import 'base/os.dart';
|
|||||||
import 'base/platform.dart';
|
import 'base/platform.dart';
|
||||||
import 'base/version.dart';
|
import 'base/version.dart';
|
||||||
import 'convert.dart';
|
import 'convert.dart';
|
||||||
import 'dart/language_version.dart';
|
|
||||||
import 'dart/package_map.dart';
|
import 'dart/package_map.dart';
|
||||||
import 'features.dart';
|
import 'features.dart';
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
@ -37,18 +36,11 @@ class Plugin {
|
|||||||
@required this.name,
|
@required this.name,
|
||||||
@required this.path,
|
@required this.path,
|
||||||
@required this.platforms,
|
@required this.platforms,
|
||||||
@required this.defaultPackagePlatforms,
|
|
||||||
@required this.pluginDartClassPlatforms,
|
|
||||||
@required this.dependencies,
|
@required this.dependencies,
|
||||||
@required this.isDirectDependency,
|
|
||||||
this.implementsPackage,
|
|
||||||
}) : assert(name != null),
|
}) : assert(name != null),
|
||||||
assert(path != null),
|
assert(path != null),
|
||||||
assert(platforms != null),
|
assert(platforms != null),
|
||||||
assert(defaultPackagePlatforms != null),
|
assert(dependencies != null);
|
||||||
assert(pluginDartClassPlatforms != null),
|
|
||||||
assert(dependencies != null),
|
|
||||||
assert(isDirectDependency != null);
|
|
||||||
|
|
||||||
/// Parses [Plugin] specification from the provided pluginYaml.
|
/// Parses [Plugin] specification from the provided pluginYaml.
|
||||||
///
|
///
|
||||||
@ -84,30 +76,15 @@ class Plugin {
|
|||||||
YamlMap pluginYaml,
|
YamlMap pluginYaml,
|
||||||
List<String> dependencies, {
|
List<String> dependencies, {
|
||||||
@required FileSystem fileSystem,
|
@required FileSystem fileSystem,
|
||||||
Set<String> appDependencies,
|
|
||||||
}) {
|
}) {
|
||||||
final List<String> errors = validatePluginYaml(pluginYaml);
|
final List<String> errors = validatePluginYaml(pluginYaml);
|
||||||
if (errors.isNotEmpty) {
|
if (errors.isNotEmpty) {
|
||||||
throwToolExit('Invalid plugin specification $name.\n${errors.join('\n')}');
|
throwToolExit('Invalid plugin specification $name.\n${errors.join('\n')}');
|
||||||
}
|
}
|
||||||
if (pluginYaml != null && pluginYaml['platforms'] != null) {
|
if (pluginYaml != null && pluginYaml['platforms'] != null) {
|
||||||
return Plugin._fromMultiPlatformYaml(
|
return Plugin._fromMultiPlatformYaml(name, path, pluginYaml, dependencies, fileSystem);
|
||||||
name,
|
|
||||||
path,
|
|
||||||
pluginYaml,
|
|
||||||
dependencies,
|
|
||||||
fileSystem,
|
|
||||||
appDependencies != null && appDependencies.contains(name),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return Plugin._fromLegacyYaml(
|
return Plugin._fromLegacyYaml(name, path, pluginYaml, dependencies, fileSystem);
|
||||||
name,
|
|
||||||
path,
|
|
||||||
pluginYaml,
|
|
||||||
dependencies,
|
|
||||||
fileSystem,
|
|
||||||
appDependencies != null && appDependencies.contains(name),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Plugin._fromMultiPlatformYaml(
|
factory Plugin._fromMultiPlatformYaml(
|
||||||
@ -116,7 +93,6 @@ class Plugin {
|
|||||||
dynamic pluginYaml,
|
dynamic pluginYaml,
|
||||||
List<String> dependencies,
|
List<String> dependencies,
|
||||||
FileSystem fileSystem,
|
FileSystem fileSystem,
|
||||||
bool isDirectDependency,
|
|
||||||
) {
|
) {
|
||||||
assert (pluginYaml != null && pluginYaml['platforms'] != null,
|
assert (pluginYaml != null && pluginYaml['platforms'] != null,
|
||||||
'Invalid multi-platform plugin specification $name.');
|
'Invalid multi-platform plugin specification $name.');
|
||||||
@ -161,47 +137,11 @@ class Plugin {
|
|||||||
WindowsPlugin.fromYaml(name, platformsYaml[WindowsPlugin.kConfigKey] as YamlMap);
|
WindowsPlugin.fromYaml(name, platformsYaml[WindowsPlugin.kConfigKey] as YamlMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String defaultPackageForLinux =
|
|
||||||
_getDefaultPackageForPlatform(platformsYaml, LinuxPlugin.kConfigKey);
|
|
||||||
|
|
||||||
final String defaultPackageForMacOS =
|
|
||||||
_getDefaultPackageForPlatform(platformsYaml, MacOSPlugin.kConfigKey);
|
|
||||||
|
|
||||||
final String defaultPackageForWindows =
|
|
||||||
_getDefaultPackageForPlatform(platformsYaml, WindowsPlugin.kConfigKey);
|
|
||||||
|
|
||||||
final String defaultPluginDartClassForLinux =
|
|
||||||
_getPluginDartClassForPlatform(platformsYaml, LinuxPlugin.kConfigKey);
|
|
||||||
|
|
||||||
final String defaultPluginDartClassForMacOS =
|
|
||||||
_getPluginDartClassForPlatform(platformsYaml, MacOSPlugin.kConfigKey);
|
|
||||||
|
|
||||||
final String defaultPluginDartClassForWindows =
|
|
||||||
_getPluginDartClassForPlatform(platformsYaml, WindowsPlugin.kConfigKey);
|
|
||||||
|
|
||||||
return Plugin(
|
return Plugin(
|
||||||
name: name,
|
name: name,
|
||||||
path: path,
|
path: path,
|
||||||
platforms: platforms,
|
platforms: platforms,
|
||||||
defaultPackagePlatforms: <String, String>{
|
|
||||||
if (defaultPackageForLinux != null)
|
|
||||||
LinuxPlugin.kConfigKey : defaultPackageForLinux,
|
|
||||||
if (defaultPackageForMacOS != null)
|
|
||||||
MacOSPlugin.kConfigKey : defaultPackageForMacOS,
|
|
||||||
if (defaultPackageForWindows != null)
|
|
||||||
WindowsPlugin.kConfigKey : defaultPackageForWindows,
|
|
||||||
},
|
|
||||||
pluginDartClassPlatforms: <String, String>{
|
|
||||||
if (defaultPluginDartClassForLinux != null)
|
|
||||||
LinuxPlugin.kConfigKey : defaultPluginDartClassForLinux,
|
|
||||||
if (defaultPluginDartClassForMacOS != null)
|
|
||||||
MacOSPlugin.kConfigKey : defaultPluginDartClassForMacOS,
|
|
||||||
if (defaultPluginDartClassForWindows != null)
|
|
||||||
WindowsPlugin.kConfigKey : defaultPluginDartClassForWindows,
|
|
||||||
},
|
|
||||||
dependencies: dependencies,
|
dependencies: dependencies,
|
||||||
isDirectDependency: isDirectDependency,
|
|
||||||
implementsPackage: pluginYaml['implements'] != null ? pluginYaml['implements'] as String : '',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +151,6 @@ class Plugin {
|
|||||||
dynamic pluginYaml,
|
dynamic pluginYaml,
|
||||||
List<String> dependencies,
|
List<String> dependencies,
|
||||||
FileSystem fileSystem,
|
FileSystem fileSystem,
|
||||||
bool isDirectDependency,
|
|
||||||
) {
|
) {
|
||||||
final Map<String, PluginPlatform> platforms = <String, PluginPlatform>{};
|
final Map<String, PluginPlatform> platforms = <String, PluginPlatform>{};
|
||||||
final String pluginClass = pluginYaml['pluginClass'] as String;
|
final String pluginClass = pluginYaml['pluginClass'] as String;
|
||||||
@ -239,10 +178,7 @@ class Plugin {
|
|||||||
name: name,
|
name: name,
|
||||||
path: path,
|
path: path,
|
||||||
platforms: platforms,
|
platforms: platforms,
|
||||||
defaultPackagePlatforms: <String, String>{},
|
|
||||||
pluginDartClassPlatforms: <String, String>{},
|
|
||||||
dependencies: dependencies,
|
dependencies: dependencies,
|
||||||
isDirectDependency: isDirectDependency,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,41 +295,11 @@ class Plugin {
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _supportsPlatform(YamlMap platformsYaml, String platformKey) {
|
static bool _providesImplementationForPlatform(YamlMap platformsYaml, String platformKey) {
|
||||||
if (!platformsYaml.containsKey(platformKey)) {
|
if (!platformsYaml.containsKey(platformKey)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (platformsYaml[platformKey] is YamlMap) {
|
if ((platformsYaml[platformKey] as YamlMap).containsKey('default_package')) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String _getDefaultPackageForPlatform(YamlMap platformsYaml, String platformKey) {
|
|
||||||
if (!_supportsPlatform(platformsYaml, platformKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ((platformsYaml[platformKey] as YamlMap).containsKey(kDefaultPackage)) {
|
|
||||||
return (platformsYaml[platformKey] as YamlMap)[kDefaultPackage] as String;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String _getPluginDartClassForPlatform(YamlMap platformsYaml, String platformKey) {
|
|
||||||
if (!_supportsPlatform(platformsYaml, platformKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if ((platformsYaml[platformKey] as YamlMap).containsKey(kDartPluginClass)) {
|
|
||||||
return (platformsYaml[platformKey] as YamlMap)[kDartPluginClass] as String;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _providesImplementationForPlatform(YamlMap platformsYaml, String platformKey) {
|
|
||||||
if (!_supportsPlatform(platformsYaml, platformKey)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((platformsYaml[platformKey] as YamlMap).containsKey(kDefaultPackage)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -402,28 +308,14 @@ class Plugin {
|
|||||||
final String name;
|
final String name;
|
||||||
final String path;
|
final String path;
|
||||||
|
|
||||||
/// The name of the interface package that this plugin implements.
|
|
||||||
/// If [null], this plugin doesn't implement an interface.
|
|
||||||
final String implementsPackage;
|
|
||||||
|
|
||||||
/// The name of the packages this plugin depends on.
|
/// The name of the packages this plugin depends on.
|
||||||
final List<String> dependencies;
|
final List<String> dependencies;
|
||||||
|
|
||||||
/// This is a mapping from platform config key to the plugin platform spec.
|
/// This is a mapping from platform config key to the plugin platform spec.
|
||||||
final Map<String, PluginPlatform> platforms;
|
final Map<String, PluginPlatform> platforms;
|
||||||
|
|
||||||
/// This is a mapping from platform config key to the default package implementation.
|
|
||||||
final Map<String, String> defaultPackagePlatforms;
|
|
||||||
|
|
||||||
/// This is a mapping from platform config key to the plugin class for the given platform.
|
|
||||||
final Map<String, String> pluginDartClassPlatforms;
|
|
||||||
|
|
||||||
/// Whether this plugin is a direct dependency of the app.
|
|
||||||
/// If [false], the plugin is a dependency of another plugin.
|
|
||||||
final bool isDirectDependency;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin _pluginFromPackage(String name, Uri packageRoot, Set<String> appDependencies) {
|
Plugin _pluginFromPackage(String name, Uri packageRoot) {
|
||||||
final String pubspecPath = globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml'));
|
final String pubspecPath = globals.fs.path.fromUri(packageRoot.resolve('pubspec.yaml'));
|
||||||
if (!globals.fs.isFileSync(pubspecPath)) {
|
if (!globals.fs.isFileSync(pubspecPath)) {
|
||||||
return null;
|
return null;
|
||||||
@ -452,7 +344,6 @@ Plugin _pluginFromPackage(String name, Uri packageRoot, Set<String> appDependenc
|
|||||||
flutterConfig['plugin'] as YamlMap,
|
flutterConfig['plugin'] as YamlMap,
|
||||||
dependencies == null ? <String>[] : <String>[...dependencies.keys.cast<String>()],
|
dependencies == null ? <String>[] : <String>[...dependencies.keys.cast<String>()],
|
||||||
fileSystem: globals.fs,
|
fileSystem: globals.fs,
|
||||||
appDependencies: appDependencies,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,11 +360,7 @@ Future<List<Plugin>> findPlugins(FlutterProject project, { bool throwOnError = t
|
|||||||
);
|
);
|
||||||
for (final Package package in packageConfig.packages) {
|
for (final Package package in packageConfig.packages) {
|
||||||
final Uri packageRoot = package.packageUriRoot.resolve('..');
|
final Uri packageRoot = package.packageUriRoot.resolve('..');
|
||||||
final Plugin plugin = _pluginFromPackage(
|
final Plugin plugin = _pluginFromPackage(package.name, packageRoot);
|
||||||
package.name,
|
|
||||||
packageRoot,
|
|
||||||
project.manifest.dependencies,
|
|
||||||
);
|
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
plugins.add(plugin);
|
plugins.add(plugin);
|
||||||
}
|
}
|
||||||
@ -481,134 +368,6 @@ Future<List<Plugin>> findPlugins(FlutterProject project, { bool throwOnError = t
|
|||||||
return plugins;
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Metadata associated with the resolution of a platform interface of a plugin.
|
|
||||||
class PluginInterfaceResolution {
|
|
||||||
PluginInterfaceResolution({
|
|
||||||
@required this.plugin,
|
|
||||||
this.platform,
|
|
||||||
}) : assert(plugin != null);
|
|
||||||
|
|
||||||
/// The plugin.
|
|
||||||
final Plugin plugin;
|
|
||||||
// The name of the platform that this plugin implements.
|
|
||||||
final String platform;
|
|
||||||
|
|
||||||
Map<String, String> toMap() {
|
|
||||||
return <String, String> {
|
|
||||||
'pluginName': plugin.name,
|
|
||||||
'platform': platform,
|
|
||||||
'dartClass': plugin.pluginDartClassPlatforms[platform],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Resolves the platform implementation for Dart-only plugins.
|
|
||||||
///
|
|
||||||
/// * If there are multiple direct pub dependencies on packages that implement the
|
|
||||||
/// frontend plugin for the current platform, fail.
|
|
||||||
/// * If there is a single direct dependency on a package that implements the
|
|
||||||
/// frontend plugin for the target platform, this package is the selected implementation.
|
|
||||||
/// * If there is no direct dependency on a package that implements the frontend
|
|
||||||
/// plugin for the target platform, and the frontend plugin has a default implementation
|
|
||||||
/// for the target platform the default implementation is selected.
|
|
||||||
/// * Else fail.
|
|
||||||
///
|
|
||||||
/// For more details, https://flutter.dev/go/federated-plugins.
|
|
||||||
List<PluginInterfaceResolution> resolvePlatformImplementation(
|
|
||||||
List<Plugin> plugins, {
|
|
||||||
bool throwOnPluginPubspecError = true,
|
|
||||||
}) {
|
|
||||||
final List<String> platforms = <String>[
|
|
||||||
LinuxPlugin.kConfigKey,
|
|
||||||
MacOSPlugin.kConfigKey,
|
|
||||||
WindowsPlugin.kConfigKey,
|
|
||||||
];
|
|
||||||
final Map<String, PluginInterfaceResolution> directDependencyResolutions
|
|
||||||
= <String, PluginInterfaceResolution>{};
|
|
||||||
final Map<String, String> defaultImplementations = <String, String>{};
|
|
||||||
bool didFindError = false;
|
|
||||||
|
|
||||||
for (final Plugin plugin in plugins) {
|
|
||||||
for (final String platform in platforms) {
|
|
||||||
// The plugin doesn't implement this platform.
|
|
||||||
if (plugin.platforms[platform] == null &&
|
|
||||||
plugin.defaultPackagePlatforms[platform] == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// The plugin doesn't implement an interface, verify that it has a default implementation.
|
|
||||||
if (plugin.implementsPackage == null || plugin.implementsPackage.isEmpty) {
|
|
||||||
final String defaultImplementation = plugin.defaultPackagePlatforms[platform];
|
|
||||||
if (defaultImplementation == null) {
|
|
||||||
if (throwOnPluginPubspecError) {
|
|
||||||
globals.printError(
|
|
||||||
'Plugin `${plugin.name}` doesn\'t implement a plugin interface, nor sets '
|
|
||||||
'a default implementation in pubspec.yaml.\n\n'
|
|
||||||
'To set a default implementation, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' platforms:\n'
|
|
||||||
' $platform:\n'
|
|
||||||
' $kDefaultPackage: <plugin-implementation>\n'
|
|
||||||
'\n'
|
|
||||||
'To implement an interface, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' implements: <plugin-interface>'
|
|
||||||
'\n'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
didFindError = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
defaultImplementations['$platform/${plugin.name}'] = defaultImplementation;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (plugin.pluginDartClassPlatforms[platform] == null ||
|
|
||||||
plugin.pluginDartClassPlatforms[platform] == 'none') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final String resolutionKey = '$platform/${plugin.implementsPackage}';
|
|
||||||
if (directDependencyResolutions.containsKey(resolutionKey)) {
|
|
||||||
final PluginInterfaceResolution currResolution = directDependencyResolutions[resolutionKey];
|
|
||||||
if (currResolution.plugin.isDirectDependency && plugin.isDirectDependency) {
|
|
||||||
if (throwOnPluginPubspecError) {
|
|
||||||
globals.printError(
|
|
||||||
'Plugin `${plugin.name}` implements an interface for `$platform`, which was already '
|
|
||||||
'implemented by plugin `${currResolution.plugin.name}`.\n'
|
|
||||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
|
||||||
'\n\n'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
didFindError = true;
|
|
||||||
}
|
|
||||||
if (currResolution.plugin.isDirectDependency) {
|
|
||||||
// Use the plugin implementation added by the user as a direct dependency.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
directDependencyResolutions[resolutionKey] = PluginInterfaceResolution(
|
|
||||||
plugin: plugin,
|
|
||||||
platform: platform,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (didFindError && throwOnPluginPubspecError) {
|
|
||||||
throwToolExit('Please resolve the errors');
|
|
||||||
}
|
|
||||||
final List<PluginInterfaceResolution> finalResolution = <PluginInterfaceResolution>[];
|
|
||||||
for (final MapEntry<String, PluginInterfaceResolution> resolution in directDependencyResolutions.entries) {
|
|
||||||
if (resolution.value.plugin.isDirectDependency) {
|
|
||||||
finalResolution.add(resolution.value);
|
|
||||||
} else if (defaultImplementations.containsKey(resolution.key)) {
|
|
||||||
// Pick the default implementation.
|
|
||||||
if (defaultImplementations[resolution.key] == resolution.value.plugin.name) {
|
|
||||||
finalResolution.add(resolution.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return finalResolution;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Key strings for the .flutter-plugins-dependencies file.
|
// Key strings for the .flutter-plugins-dependencies file.
|
||||||
const String _kFlutterPluginsPluginListKey = 'plugins';
|
const String _kFlutterPluginsPluginListKey = 'plugins';
|
||||||
const String _kFlutterPluginsNameKey = 'name';
|
const String _kFlutterPluginsNameKey = 'name';
|
||||||
@ -925,73 +684,11 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates the Dart plugin registrant, which allows to bind a platform
|
|
||||||
/// implementation of a Dart only plugin to its interface.
|
|
||||||
/// The new entrypoint wraps [currentMainUri], adds a [_registerPlugins] function,
|
|
||||||
/// and writes the file to [newMainDart].
|
|
||||||
///
|
|
||||||
/// [mainFile] is the main entrypoint file. e.g. /<app>/lib/main.dart.
|
|
||||||
///
|
|
||||||
/// Returns [true] if it's necessary to create a plugin registrant, and
|
|
||||||
/// 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.
|
|
||||||
Future<bool> generateMainDartWithPluginRegistrant(
|
|
||||||
FlutterProject rootProject,
|
|
||||||
PackageConfig packageConfig,
|
|
||||||
String currentMainUri,
|
|
||||||
File newMainDart,
|
|
||||||
File mainFile, {
|
|
||||||
bool throwOnPluginPubspecError,
|
|
||||||
}) async {
|
|
||||||
final List<Plugin> plugins = await findPlugins(rootProject);
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(
|
|
||||||
plugins,
|
|
||||||
throwOnPluginPubspecError: throwOnPluginPubspecError,
|
|
||||||
);
|
|
||||||
final LanguageVersion entrypointVersion = determineLanguageVersion(
|
|
||||||
mainFile,
|
|
||||||
packageConfig.packageOf(mainFile.absolute.uri),
|
|
||||||
);
|
|
||||||
final Map<String, dynamic> templateContext = <String, dynamic>{
|
|
||||||
'mainEntrypoint': currentMainUri,
|
|
||||||
'dartLanguageVersion': entrypointVersion.toString(),
|
|
||||||
LinuxPlugin.kConfigKey: <dynamic>[],
|
|
||||||
MacOSPlugin.kConfigKey: <dynamic>[],
|
|
||||||
WindowsPlugin.kConfigKey: <dynamic>[],
|
|
||||||
};
|
|
||||||
bool didFindPlugin = false;
|
|
||||||
for (final PluginInterfaceResolution resolution in resolutions) {
|
|
||||||
assert(templateContext.containsKey(resolution.platform));
|
|
||||||
(templateContext[resolution.platform] as List<dynamic>).add(resolution.toMap());
|
|
||||||
didFindPlugin = true;
|
|
||||||
}
|
|
||||||
if (!didFindPlugin) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
_renderTemplateToFile(
|
|
||||||
_dartPluginRegistryForDesktopTemplate,
|
|
||||||
templateContext,
|
|
||||||
newMainDart.path,
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
} on FileSystemException catch (error) {
|
|
||||||
throwToolExit('Unable to write ${newMainDart.path}, received error: $error');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const String _objcPluginRegistryHeaderTemplate = '''
|
const String _objcPluginRegistryHeaderTemplate = '''
|
||||||
//
|
//
|
||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GeneratedPluginRegistrant_h
|
#ifndef GeneratedPluginRegistrant_h
|
||||||
#define GeneratedPluginRegistrant_h
|
#define GeneratedPluginRegistrant_h
|
||||||
|
|
||||||
@ -1012,8 +709,6 @@ const String _objcPluginRegistryImplementationTemplate = '''
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#import "GeneratedPluginRegistrant.h"
|
#import "GeneratedPluginRegistrant.h"
|
||||||
|
|
||||||
{{#plugins}}
|
{{#plugins}}
|
||||||
@ -1040,8 +735,6 @@ const String _swiftPluginRegistryTemplate = '''
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
import {{framework}}
|
import {{framework}}
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@ -1084,7 +777,7 @@ Depends on all your plugins, and provides a function to register them.
|
|||||||
end
|
end
|
||||||
''';
|
''';
|
||||||
|
|
||||||
const String _dartPluginRegistryForWebTemplate = '''
|
const String _dartPluginRegistryTemplate = '''
|
||||||
//
|
//
|
||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
@ -1106,54 +799,11 @@ void registerPlugins(Registrar registrar) {
|
|||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
|
||||||
// TODO(egarciad): Evaluate merging the web and desktop plugin registry templates.
|
|
||||||
const String _dartPluginRegistryForDesktopTemplate = '''
|
|
||||||
//
|
|
||||||
// Generated file. Do not edit.
|
|
||||||
//
|
|
||||||
|
|
||||||
// @dart = {{dartLanguageVersion}}
|
|
||||||
|
|
||||||
import '{{mainEntrypoint}}' as entrypoint;
|
|
||||||
import 'dart:io'; // flutter_ignore: dart_io_import.
|
|
||||||
{{#linux}}
|
|
||||||
import 'package:{{pluginName}}/{{pluginName}}.dart';
|
|
||||||
{{/linux}}
|
|
||||||
{{#macos}}
|
|
||||||
import 'package:{{pluginName}}/{{pluginName}}.dart';
|
|
||||||
{{/macos}}
|
|
||||||
{{#windows}}
|
|
||||||
import 'package:{{pluginName}}/{{pluginName}}.dart';
|
|
||||||
{{/windows}}
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
|
||||||
void _registerPlugins() {
|
|
||||||
if (Platform.isLinux) {
|
|
||||||
{{#linux}}
|
|
||||||
{{dartClass}}.registerWith();
|
|
||||||
{{/linux}}
|
|
||||||
} else if (Platform.isMacOS) {
|
|
||||||
{{#macos}}
|
|
||||||
{{dartClass}}.registerWith();
|
|
||||||
{{/macos}}
|
|
||||||
} else if (Platform.isWindows) {
|
|
||||||
{{#windows}}
|
|
||||||
{{dartClass}}.registerWith();
|
|
||||||
{{/windows}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void main() {
|
|
||||||
entrypoint.main();
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
const String _cppPluginRegistryHeaderTemplate = '''
|
const String _cppPluginRegistryHeaderTemplate = '''
|
||||||
//
|
//
|
||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||||
#define GENERATED_PLUGIN_REGISTRANT_
|
#define GENERATED_PLUGIN_REGISTRANT_
|
||||||
|
|
||||||
@ -1170,8 +820,6 @@ const String _cppPluginRegistryImplementationTemplate = '''
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
{{#plugins}}
|
{{#plugins}}
|
||||||
@ -1191,8 +839,6 @@ const String _linuxPluginRegistryHeaderTemplate = '''
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
#ifndef GENERATED_PLUGIN_REGISTRANT_
|
||||||
#define GENERATED_PLUGIN_REGISTRANT_
|
#define GENERATED_PLUGIN_REGISTRANT_
|
||||||
|
|
||||||
@ -1209,8 +855,6 @@ const String _linuxPluginRegistryImplementationTemplate = '''
|
|||||||
// Generated file. Do not edit.
|
// Generated file. Do not edit.
|
||||||
//
|
//
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
{{#plugins}}
|
{{#plugins}}
|
||||||
@ -1396,7 +1040,7 @@ Future<void> _writeWebPluginRegistrant(FlutterProject project, List<Plugin> plug
|
|||||||
return ErrorHandlingFileSystem.deleteIfExists(file);
|
return ErrorHandlingFileSystem.deleteIfExists(file);
|
||||||
} else {
|
} else {
|
||||||
_renderTemplateToFile(
|
_renderTemplateToFile(
|
||||||
_dartPluginRegistryForWebTemplate,
|
_dartPluginRegistryTemplate,
|
||||||
context,
|
context,
|
||||||
filePath,
|
filePath,
|
||||||
);
|
);
|
||||||
|
@ -920,7 +920,6 @@ abstract class ResidentRunner {
|
|||||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
outputDir: globals.fs.directory(getBuildDirectory()),
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
projectDir: globals.fs.currentDirectory,
|
projectDir: globals.fs.currentDirectory,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
_lastBuild = await globals.buildSystem.buildIncremental(
|
_lastBuild = await globals.buildSystem.buildIncremental(
|
||||||
const GenerateLocalizationsTarget(),
|
const GenerateLocalizationsTarget(),
|
||||||
|
@ -26,7 +26,6 @@ import 'devfs.dart';
|
|||||||
import 'device.dart';
|
import 'device.dart';
|
||||||
import 'features.dart';
|
import 'features.dart';
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
import 'project.dart';
|
|
||||||
import 'reporting/reporting.dart';
|
import 'reporting/reporting.dart';
|
||||||
import 'resident_devtools_handler.dart';
|
import 'resident_devtools_handler.dart';
|
||||||
import 'resident_runner.dart';
|
import 'resident_runner.dart';
|
||||||
@ -315,15 +314,6 @@ class HotRunner extends ResidentRunner {
|
|||||||
bool enableDevTools = false,
|
bool enableDevTools = false,
|
||||||
String route,
|
String route,
|
||||||
}) async {
|
}) async {
|
||||||
File mainFile = globals.fs.file(mainPath);
|
|
||||||
// `generated_main.dart` contains the Dart plugin registry.
|
|
||||||
final Directory buildDir = FlutterProject.current()
|
|
||||||
.directory
|
|
||||||
.childDirectory(globals.fs.path.join('.dart_tool', 'flutter_build'));
|
|
||||||
final File newMainDart = buildDir?.childFile('generated_main.dart');
|
|
||||||
if (newMainDart != null && newMainDart.existsSync()) {
|
|
||||||
mainFile = newMainDart;
|
|
||||||
}
|
|
||||||
firstBuildTime = DateTime.now();
|
firstBuildTime = DateTime.now();
|
||||||
|
|
||||||
final List<Future<bool>> startupTasks = <Future<bool>>[];
|
final List<Future<bool>> startupTasks = <Future<bool>>[];
|
||||||
@ -336,7 +326,7 @@ class HotRunner extends ResidentRunner {
|
|||||||
if (device.generator != null) {
|
if (device.generator != null) {
|
||||||
startupTasks.add(
|
startupTasks.add(
|
||||||
device.generator.recompile(
|
device.generator.recompile(
|
||||||
mainFile.uri,
|
globals.fs.file(mainPath).uri,
|
||||||
<Uri>[],
|
<Uri>[],
|
||||||
// When running without a provided applicationBinary, the tool will
|
// When running without a provided applicationBinary, the tool will
|
||||||
// simultaneously run the initial frontend_server compilation and
|
// simultaneously run the initial frontend_server compilation and
|
||||||
|
@ -1152,7 +1152,6 @@ abstract class FlutterCommand extends Command<void> {
|
|||||||
outputDir: globals.fs.directory(getBuildDirectory()),
|
outputDir: globals.fs.directory(getBuildDirectory()),
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
projectDir: project.directory,
|
projectDir: project.directory,
|
||||||
generateDartPluginRegistry: true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await generateLocalizationsSyntheticPackage(
|
await generateLocalizationsSyntheticPackage(
|
||||||
|
@ -69,8 +69,6 @@ Future<void> buildWeb(
|
|||||||
? null
|
? null
|
||||||
: globals.flutterVersion.engineRevision,
|
: globals.flutterVersion.engineRevision,
|
||||||
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
|
||||||
// Web uses a different Dart plugin registry.
|
|
||||||
generateDartPluginRegistry: false,
|
|
||||||
));
|
));
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
for (final ExceptionMeasurement measurement in result.exceptions.values) {
|
for (final ExceptionMeasurement measurement in result.exceptions.values) {
|
||||||
|
@ -36,7 +36,6 @@ void main() {
|
|||||||
logger: logger,
|
logger: logger,
|
||||||
processManager: globals.processManager,
|
processManager: globals.processManager,
|
||||||
engineVersion: 'invalidEngineVersion',
|
engineVersion: 'invalidEngineVersion',
|
||||||
generateDartPluginRegistry: false,
|
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -220,39 +220,6 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(plugin.platforms, <String, PluginPlatform>{});
|
expect(plugin.platforms, <String, PluginPlatform>{});
|
||||||
expect(plugin.defaultPackagePlatforms, <String, String>{
|
|
||||||
'linux': 'sample_package_linux',
|
|
||||||
'macos': 'sample_package_macos',
|
|
||||||
'windows': 'sample_package_windows',
|
|
||||||
});
|
|
||||||
expect(plugin.pluginDartClassPlatforms, <String, String>{});
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('Desktop plugin parsing allows a dartPluginClass field', () {
|
|
||||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
|
||||||
const String pluginYamlRaw =
|
|
||||||
'platforms:\n'
|
|
||||||
' linux:\n'
|
|
||||||
' dartPluginClass: LinuxClass\n'
|
|
||||||
' macos:\n'
|
|
||||||
' dartPluginClass: MacOSClass\n'
|
|
||||||
' windows:\n'
|
|
||||||
' dartPluginClass: WindowsClass\n';
|
|
||||||
|
|
||||||
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
|
|
||||||
final Plugin plugin = Plugin.fromYaml(
|
|
||||||
_kTestPluginName,
|
|
||||||
_kTestPluginPath,
|
|
||||||
pluginYaml,
|
|
||||||
const <String>[],
|
|
||||||
fileSystem: fileSystem,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(plugin.pluginDartClassPlatforms, <String, String>{
|
|
||||||
'linux': 'LinuxClass',
|
|
||||||
'macos': 'MacOSClass',
|
|
||||||
'windows': 'WindowsClass',
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('Plugin parsing throws a fatal error on an empty plugin', () {
|
testWithoutContext('Plugin parsing throws a fatal error on an empty plugin', () {
|
||||||
|
@ -14,8 +14,6 @@ import 'package:flutter_tools/src/base/platform.dart';
|
|||||||
import 'package:flutter_tools/src/base/time.dart';
|
import 'package:flutter_tools/src/base/time.dart';
|
||||||
import 'package:flutter_tools/src/base/utils.dart';
|
import 'package:flutter_tools/src/base/utils.dart';
|
||||||
import 'package:flutter_tools/src/features.dart';
|
import 'package:flutter_tools/src/features.dart';
|
||||||
import 'package:flutter_tools/src/dart/package_map.dart';
|
|
||||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||||
import 'package:flutter_tools/src/plugins.dart';
|
import 'package:flutter_tools/src/plugins.dart';
|
||||||
@ -23,7 +21,6 @@ import 'package:flutter_tools/src/project.dart';
|
|||||||
import 'package:flutter_tools/src/version.dart';
|
import 'package:flutter_tools/src/version.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:package_config/package_config.dart';
|
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
@ -36,7 +33,6 @@ void main() {
|
|||||||
group('plugins', () {
|
group('plugins', () {
|
||||||
FileSystem fs;
|
FileSystem fs;
|
||||||
MockFlutterProject flutterProject;
|
MockFlutterProject flutterProject;
|
||||||
MockFlutterManifest flutterManifest;
|
|
||||||
MockIosProject iosProject;
|
MockIosProject iosProject;
|
||||||
MockMacOSProject macosProject;
|
MockMacOSProject macosProject;
|
||||||
MockAndroidProject androidProject;
|
MockAndroidProject androidProject;
|
||||||
@ -53,12 +49,6 @@ void main() {
|
|||||||
// Adds basic properties to the flutterProject and its subprojects.
|
// Adds basic properties to the flutterProject and its subprojects.
|
||||||
void setUpProject(FileSystem fileSystem) {
|
void setUpProject(FileSystem fileSystem) {
|
||||||
flutterProject = MockFlutterProject();
|
flutterProject = MockFlutterProject();
|
||||||
|
|
||||||
flutterManifest = MockFlutterManifest();
|
|
||||||
when(flutterManifest.dependencies).thenReturn(<String>{});
|
|
||||||
|
|
||||||
when(flutterProject.manifest).thenReturn(flutterManifest);
|
|
||||||
|
|
||||||
when(flutterProject.directory).thenReturn(fileSystem.systemTempDirectory.childDirectory('app'));
|
when(flutterProject.directory).thenReturn(fileSystem.systemTempDirectory.childDirectory('app'));
|
||||||
// TODO(franciscojma): Remove logic for .flutter-plugins once it's deprecated.
|
// TODO(franciscojma): Remove logic for .flutter-plugins once it's deprecated.
|
||||||
when(flutterProject.flutterPluginsFile).thenReturn(flutterProject.directory.childFile('.flutter-plugins'));
|
when(flutterProject.flutterPluginsFile).thenReturn(flutterProject.directory.childFile('.flutter-plugins'));
|
||||||
@ -1300,799 +1290,6 @@ flutter:
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('resolvePlatformImplementation', () {
|
|
||||||
test('selects implementation from direct dependency', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'url_launcher_linux',
|
|
||||||
'url_launcher_macos',
|
|
||||||
};
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_macos',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'macos': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginMacOS',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'undirect_dependency_plugin',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'windows': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginWindows',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_macos',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'macos': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginMacOS',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(resolutions.length, equals(2));
|
|
||||||
expect(resolutions[0].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'url_launcher_linux',
|
|
||||||
'dartClass': 'UrlLauncherPluginLinux',
|
|
||||||
'platform': 'linux',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(resolutions[1].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'url_launcher_macos',
|
|
||||||
'dartClass': 'UrlLauncherPluginMacOS',
|
|
||||||
'platform': 'macos',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('selects default implementation', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{};
|
|
||||||
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'default_package': 'url_launcher_linux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
expect(resolutions.length, equals(1));
|
|
||||||
expect(resolutions[0].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'url_launcher_linux',
|
|
||||||
'dartClass': 'UrlLauncherPluginLinux',
|
|
||||||
'platform': 'linux',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('selects default implementation if interface is direct dependency', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{'url_launcher'};
|
|
||||||
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'default_package': 'url_launcher_linux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
expect(resolutions.length, equals(1));
|
|
||||||
expect(resolutions[0].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'url_launcher_linux',
|
|
||||||
'dartClass': 'UrlLauncherPluginLinux',
|
|
||||||
'platform': 'linux',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('selects user selected implementation despites default implementation', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'user_selected_url_launcher_implementation',
|
|
||||||
'url_launcher',
|
|
||||||
};
|
|
||||||
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'default_package': 'url_launcher_linux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'user_selected_url_launcher_implementation',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
expect(resolutions.length, equals(1));
|
|
||||||
expect(resolutions[0].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'user_selected_url_launcher_implementation',
|
|
||||||
'dartClass': 'UrlLauncherPluginLinux',
|
|
||||||
'platform': 'linux',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('selects user selected implementation despites default implementation', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'user_selected_url_launcher_implementation',
|
|
||||||
'url_launcher',
|
|
||||||
};
|
|
||||||
|
|
||||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'default_package': 'url_launcher_linux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'user_selected_url_launcher_implementation',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
expect(resolutions.length, equals(1));
|
|
||||||
expect(resolutions[0].toMap(), equals(
|
|
||||||
<String, String>{
|
|
||||||
'pluginName': 'user_selected_url_launcher_implementation',
|
|
||||||
'dartClass': 'UrlLauncherPluginLinux',
|
|
||||||
'platform': 'linux',
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('provides error when user selected multiple implementations', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
'url_launcher_linux_2',
|
|
||||||
};
|
|
||||||
expect(() {
|
|
||||||
resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux_2',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
testLogger.errorText,
|
|
||||||
'Plugin `url_launcher_linux_2` implements an interface for `linux`, which was already implemented by plugin `url_launcher_linux_1`.\n'
|
|
||||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
|
||||||
'\n\n'
|
|
||||||
);
|
|
||||||
},
|
|
||||||
throwsToolExit(
|
|
||||||
message: 'Please resolve the errors',
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('provides all errors when user selected multiple implementations', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
'url_launcher_linux_2',
|
|
||||||
};
|
|
||||||
expect(() {
|
|
||||||
resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux_2',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'implements': 'url_launcher',
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
testLogger.errorText,
|
|
||||||
'Plugin `url_launcher_linux_2` implements an interface for `linux`, which was already implemented by plugin `url_launcher_linux_1`.\n'
|
|
||||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
|
||||||
'\n\n'
|
|
||||||
);
|
|
||||||
},
|
|
||||||
throwsToolExit(
|
|
||||||
message: 'Please resolve the errors',
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('provides error when plugin pubspec.yaml doesn\'t have "implementation" nor "default_implementation"', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
};
|
|
||||||
expect(() {
|
|
||||||
resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux_1',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
throwsToolExit(
|
|
||||||
message: 'Please resolve the errors'
|
|
||||||
));
|
|
||||||
expect(
|
|
||||||
testLogger.errorText,
|
|
||||||
'Plugin `url_launcher_linux_1` doesn\'t implement a plugin interface, '
|
|
||||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
|
||||||
'To set a default implementation, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' platforms:\n'
|
|
||||||
' linux:\n'
|
|
||||||
' default_package: <plugin-implementation>\n'
|
|
||||||
'\n'
|
|
||||||
'To implement an interface, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' implements: <plugin-interface>'
|
|
||||||
'\n\n'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('provides all errors when plugin pubspec.yaml doesn\'t have "implementation" nor "default_implementation"', () async {
|
|
||||||
final FileSystem fs = MemoryFileSystem();
|
|
||||||
final Set<String> directDependencies = <String>{
|
|
||||||
'url_launcher_linux',
|
|
||||||
'url_launcher_windows',
|
|
||||||
};
|
|
||||||
expect(() {
|
|
||||||
resolvePlatformImplementation(<Plugin>[
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_linux',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'linux': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
Plugin.fromYaml(
|
|
||||||
'url_launcher_windows',
|
|
||||||
'',
|
|
||||||
YamlMap.wrap(<String, dynamic>{
|
|
||||||
'platforms': <String, dynamic>{
|
|
||||||
'windows': <String, dynamic>{
|
|
||||||
'dartPluginClass': 'UrlLauncherPluginWindows',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<String>[],
|
|
||||||
fileSystem: fs,
|
|
||||||
appDependencies: directDependencies,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
},
|
|
||||||
throwsToolExit(
|
|
||||||
message: 'Please resolve the errors'
|
|
||||||
));
|
|
||||||
expect(
|
|
||||||
testLogger.errorText,
|
|
||||||
'Plugin `url_launcher_linux` doesn\'t implement a plugin interface, '
|
|
||||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
|
||||||
'To set a default implementation, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' platforms:\n'
|
|
||||||
' linux:\n'
|
|
||||||
' default_package: <plugin-implementation>\n'
|
|
||||||
'\n'
|
|
||||||
'To implement an interface, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' implements: <plugin-interface>'
|
|
||||||
'\n\n'
|
|
||||||
'Plugin `url_launcher_windows` doesn\'t implement a plugin interface, '
|
|
||||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
|
||||||
'To set a default implementation, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' platforms:\n'
|
|
||||||
' windows:\n'
|
|
||||||
' default_package: <plugin-implementation>\n'
|
|
||||||
'\n'
|
|
||||||
'To implement an interface, use:\n'
|
|
||||||
'flutter:\n'
|
|
||||||
' plugin:\n'
|
|
||||||
' implements: <plugin-interface>'
|
|
||||||
'\n\n'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
group('generateMainDartWithPluginRegistrant', () {
|
|
||||||
testUsingContext('Generates new entrypoint', () async {
|
|
||||||
when(flutterProject.isModule).thenReturn(false);
|
|
||||||
|
|
||||||
final List<Directory> directories = <Directory>[];
|
|
||||||
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
|
||||||
final File packagesFile = flutterProject.directory
|
|
||||||
.childFile('.packages')
|
|
||||||
..createSync(recursive: true);
|
|
||||||
|
|
||||||
final Map<String, String> plugins = <String, String>{};
|
|
||||||
plugins['url_launcher_macos'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: url_launcher
|
|
||||||
platforms:
|
|
||||||
macos:
|
|
||||||
dartPluginClass: MacOSPlugin
|
|
||||||
''';
|
|
||||||
plugins['url_launcher_linux'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: url_launcher
|
|
||||||
platforms:
|
|
||||||
linux:
|
|
||||||
dartPluginClass: LinuxPlugin
|
|
||||||
''';
|
|
||||||
plugins['url_launcher_windows'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: url_launcher
|
|
||||||
platforms:
|
|
||||||
windows:
|
|
||||||
dartPluginClass: WindowsPlugin
|
|
||||||
''';
|
|
||||||
plugins['awesome_macos'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: awesome
|
|
||||||
platforms:
|
|
||||||
macos:
|
|
||||||
dartPluginClass: AwesomeMacOS
|
|
||||||
''';
|
|
||||||
for (final MapEntry<String, String> entry in plugins.entries) {
|
|
||||||
final String name = fs.path.basename(entry.key);
|
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
|
||||||
packagesFile.writeAsStringSync(
|
|
||||||
'$name:file://${pluginDirectory.childFile('lib').uri}\n',
|
|
||||||
mode: FileMode.writeOnlyAppend);
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(entry.value);
|
|
||||||
directories.add(pluginDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
when(flutterManifest.dependencies).thenReturn(<String>{...plugins.keys});
|
|
||||||
|
|
||||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
|
||||||
libDir.createSync(recursive: true);
|
|
||||||
|
|
||||||
final File mainFile = libDir.childFile('main.dart');
|
|
||||||
mainFile.writeAsStringSync('''
|
|
||||||
// @dart = 2.8
|
|
||||||
void main() {
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final File flutterBuild = flutterProject.directory.childFile('generated_main.dart');
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
|
||||||
logger: globals.logger,
|
|
||||||
throwOnError: false,
|
|
||||||
);
|
|
||||||
final bool didGenerate = await generateMainDartWithPluginRegistrant(
|
|
||||||
flutterProject,
|
|
||||||
packageConfig,
|
|
||||||
'package:app/main.dart',
|
|
||||||
flutterBuild,
|
|
||||||
mainFile,
|
|
||||||
throwOnPluginPubspecError: true,
|
|
||||||
);
|
|
||||||
expect(didGenerate, isTrue);
|
|
||||||
expect(flutterBuild.readAsStringSync(),
|
|
||||||
'//\n'
|
|
||||||
'// Generated file. Do not edit.\n'
|
|
||||||
'//\n'
|
|
||||||
'\n'
|
|
||||||
'// @dart = 2.8\n'
|
|
||||||
'\n'
|
|
||||||
'import \'package:app/main.dart\' as entrypoint;\n'
|
|
||||||
'import \'dart:io\'; // flutter_ignore: dart_io_import.\n'
|
|
||||||
'import \'package:url_launcher_linux${fs.path.separator}url_launcher_linux.dart\';\n'
|
|
||||||
'import \'package:awesome_macos/awesome_macos.dart\';\n'
|
|
||||||
'import \'package:url_launcher_macos${fs.path.separator}url_launcher_macos.dart\';\n'
|
|
||||||
'import \'package:url_launcher_windows${fs.path.separator}url_launcher_windows.dart\';\n'
|
|
||||||
'\n'
|
|
||||||
'@pragma(\'vm:entry-point\')\n'
|
|
||||||
'void _registerPlugins() {\n'
|
|
||||||
' if (Platform.isLinux) {\n'
|
|
||||||
' LinuxPlugin.registerWith();\n'
|
|
||||||
' } else if (Platform.isMacOS) {\n'
|
|
||||||
' AwesomeMacOS.registerWith();\n'
|
|
||||||
' MacOSPlugin.registerWith();\n'
|
|
||||||
' } else if (Platform.isWindows) {\n'
|
|
||||||
' WindowsPlugin.registerWith();\n'
|
|
||||||
' }\n'
|
|
||||||
'}\n'
|
|
||||||
'void main() {\n'
|
|
||||||
' entrypoint.main();\n'
|
|
||||||
'}\n'
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
}, overrides: <Type, Generator>{
|
|
||||||
FileSystem: () => fs,
|
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('Plugin without platform support throws tool exit', () async {
|
|
||||||
when(flutterProject.isModule).thenReturn(false);
|
|
||||||
|
|
||||||
final List<Directory> directories = <Directory>[];
|
|
||||||
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
|
||||||
final File packagesFile = flutterProject.directory
|
|
||||||
.childFile('.packages')
|
|
||||||
..createSync(recursive: true);
|
|
||||||
final Map<String, String> plugins = <String, String>{};
|
|
||||||
plugins['url_launcher_macos'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: url_launcher
|
|
||||||
platforms:
|
|
||||||
macos:
|
|
||||||
invalid:
|
|
||||||
''';
|
|
||||||
for (final MapEntry<String, String> entry in plugins.entries) {
|
|
||||||
final String name = fs.path.basename(entry.key);
|
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
|
||||||
packagesFile.writeAsStringSync(
|
|
||||||
'$name:file://${pluginDirectory.childFile('lib').uri}\n',
|
|
||||||
mode: FileMode.writeOnlyAppend);
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(entry.value);
|
|
||||||
directories.add(pluginDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
when(flutterManifest.dependencies).thenReturn(<String>{...plugins.keys});
|
|
||||||
|
|
||||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
|
||||||
libDir.createSync(recursive: true);
|
|
||||||
|
|
||||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
|
||||||
final File flutterBuild = flutterProject.directory.childFile('generated_main.dart');
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
|
||||||
logger: globals.logger,
|
|
||||||
throwOnError: false,
|
|
||||||
);
|
|
||||||
await expectLater(
|
|
||||||
generateMainDartWithPluginRegistrant(
|
|
||||||
flutterProject,
|
|
||||||
packageConfig,
|
|
||||||
'package:app/main.dart',
|
|
||||||
flutterBuild,
|
|
||||||
mainFile,
|
|
||||||
throwOnPluginPubspecError: true,
|
|
||||||
), throwsToolExit(message:
|
|
||||||
'Invalid plugin specification url_launcher_macos.\n'
|
|
||||||
'Invalid "macos" plugin specification.'
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}, overrides: <Type, Generator>{
|
|
||||||
FileSystem: () => fs,
|
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
|
||||||
});
|
|
||||||
|
|
||||||
testUsingContext('Plugin with platform support without dart plugin class throws tool exit', () async {
|
|
||||||
when(flutterProject.isModule).thenReturn(false);
|
|
||||||
|
|
||||||
final List<Directory> directories = <Directory>[];
|
|
||||||
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
|
||||||
final File packagesFile = flutterProject.directory
|
|
||||||
.childFile('.packages')
|
|
||||||
..createSync(recursive: true);
|
|
||||||
final Map<String, String> plugins = <String, String>{};
|
|
||||||
plugins['url_launcher_macos'] = '''
|
|
||||||
flutter:
|
|
||||||
plugin:
|
|
||||||
implements: url_launcher
|
|
||||||
''';
|
|
||||||
for (final MapEntry<String, String> entry in plugins.entries) {
|
|
||||||
final String name = fs.path.basename(entry.key);
|
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
|
||||||
packagesFile.writeAsStringSync(
|
|
||||||
'$name:file://${pluginDirectory.childFile('lib').uri}\n',
|
|
||||||
mode: FileMode.writeOnlyAppend);
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(entry.value);
|
|
||||||
directories.add(pluginDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
when(flutterManifest.dependencies).thenReturn(<String>{...plugins.keys});
|
|
||||||
|
|
||||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
|
||||||
libDir.createSync(recursive: true);
|
|
||||||
|
|
||||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
|
||||||
final File flutterBuild = flutterProject.directory.childFile('generated_main.dart');
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
|
||||||
logger: globals.logger,
|
|
||||||
throwOnError: false,
|
|
||||||
);
|
|
||||||
await expectLater(
|
|
||||||
generateMainDartWithPluginRegistrant(
|
|
||||||
flutterProject,
|
|
||||||
packageConfig,
|
|
||||||
'package:app/main.dart',
|
|
||||||
flutterBuild,
|
|
||||||
mainFile,
|
|
||||||
throwOnPluginPubspecError: true,
|
|
||||||
), throwsToolExit(message:
|
|
||||||
'Invalid plugin specification url_launcher_macos.\n'
|
|
||||||
'Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. '
|
|
||||||
'An instruction to format the `pubspec.yaml` can be found here: '
|
|
||||||
'https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms'
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}, overrides: <Type, Generator>{
|
|
||||||
FileSystem: () => fs,
|
|
||||||
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', () {
|
||||||
|
|
||||||
Directory projectDir;
|
Directory projectDir;
|
||||||
@ -2189,7 +1386,6 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MockAndroidProject extends Mock implements AndroidProject {}
|
class MockAndroidProject extends Mock implements AndroidProject {}
|
||||||
class MockFlutterManifest extends Mock implements FlutterManifest {}
|
|
||||||
class MockFlutterProject extends Mock implements FlutterProject {}
|
class MockFlutterProject extends Mock implements FlutterProject {}
|
||||||
class MockIosProject extends Mock implements IosProject {}
|
class MockIosProject extends Mock implements IosProject {}
|
||||||
class MockMacOSProject extends Mock implements MacOSProject {}
|
class MockMacOSProject extends Mock implements MacOSProject {}
|
||||||
|
@ -110,17 +110,6 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
_testInMemory('reads dependencies from pubspec.yaml', () async {
|
|
||||||
final Directory directory = globals.fs.directory('myproject');
|
|
||||||
directory.childFile('pubspec.yaml')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(validPubspecWithDependencies);
|
|
||||||
expect(
|
|
||||||
FlutterProject.fromDirectory(directory).manifest.dependencies,
|
|
||||||
<String>{'plugin_a', 'plugin_b'},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
_testInMemory('sets up location', () async {
|
_testInMemory('sets up location', () async {
|
||||||
final Directory directory = globals.fs.directory('myproject');
|
final Directory directory = globals.fs.directory('myproject');
|
||||||
expect(
|
expect(
|
||||||
@ -925,16 +914,6 @@ name: hello
|
|||||||
flutter:
|
flutter:
|
||||||
''';
|
''';
|
||||||
|
|
||||||
String get validPubspecWithDependencies => '''
|
|
||||||
name: hello
|
|
||||||
flutter:
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
plugin_a:
|
|
||||||
plugin_b:
|
|
||||||
''';
|
|
||||||
|
|
||||||
|
|
||||||
String get invalidPubspec => '''
|
String get invalidPubspec => '''
|
||||||
name: hello
|
name: hello
|
||||||
flutter:
|
flutter:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user