mirror of
https://github.com/encounter/flutter.git
synced 2026-03-30 11:10:35 -07:00
Allow plugins that don't support the Android platform (#46282)
This commit is contained in:
@@ -59,6 +59,43 @@ Future<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
section('Create plugin C without android/ directory');
|
||||
|
||||
final Directory pluginCDirectory = Directory(path.join(tempDir.path, 'plugin_c'));
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--org',
|
||||
'io.flutter.devicelab.plugin_c',
|
||||
'--template=plugin',
|
||||
pluginCDirectory.path,
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
File(path.join(pluginCDirectory.path, 'android')).deleteSync(recursive: true);
|
||||
|
||||
final File pluginCpubspec = File(path.join(pluginCDirectory.path, 'pubspec.yaml'));
|
||||
await pluginCpubspec.writeAsString('''
|
||||
name: plugin_c
|
||||
version: 0.0.1
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
platforms:
|
||||
ios:
|
||||
pluginClass: Plugin_cPlugin
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev.28.0 <3.0.0"
|
||||
flutter: ">=1.5.0 <2.0.0"
|
||||
''', flush: true);
|
||||
|
||||
section('Write dummy Kotlin code in plugin B');
|
||||
|
||||
final File pluginBKotlinClass = File(path.join(
|
||||
@@ -81,17 +118,19 @@ public class DummyPluginBClass {
|
||||
}
|
||||
''', flush: true);
|
||||
|
||||
section('Make plugin A depend on plugin B');
|
||||
section('Make plugin A depend on plugin B and plugin C');
|
||||
|
||||
final File pubspec = File(path.join(pluginADirectory.path, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
final File pluginApubspec = File(path.join(pluginADirectory.path, 'pubspec.yaml'));
|
||||
String pluginApubspecContent = await pluginApubspec.readAsString();
|
||||
pluginApubspecContent = pluginApubspecContent.replaceFirst(
|
||||
'\ndependencies:\n',
|
||||
'\ndependencies:\n'
|
||||
' plugin_b:\n'
|
||||
' path: ${pluginBDirectory.path}\n',
|
||||
' path: ${pluginBDirectory.path}\n'
|
||||
' plugin_c:\n'
|
||||
' path: ${pluginCDirectory.path}\n',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
await pluginApubspec.writeAsString(pluginApubspecContent, flush: true);
|
||||
|
||||
section('Write Kotlin code in plugin A that references Kotlin code from plugin B');
|
||||
|
||||
@@ -142,11 +181,15 @@ public class DummyPluginAClass {
|
||||
'\"dependencyGraph\":['
|
||||
'{'
|
||||
'\"name\":\"plugin_a\",'
|
||||
'\"dependencies\":[\"plugin_b\"]'
|
||||
'\"dependencies\":[\"plugin_b\",\"plugin_c\"]'
|
||||
'},'
|
||||
'{'
|
||||
'\"name\":\"plugin_b\",'
|
||||
'\"dependencies\":[]'
|
||||
'},'
|
||||
'{'
|
||||
'\"name\":\"plugin_c\",'
|
||||
'\"dependencies\":[]'
|
||||
'}'
|
||||
']'
|
||||
'}';
|
||||
|
||||
@@ -349,7 +349,7 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
return
|
||||
}
|
||||
Project dependencyProject = project.rootProject.findProject(":$pluginDependencyName")
|
||||
if (dependencyProject == null) {
|
||||
if (!dependencyProject.projectDir.exists() || dependencyProject == null) {
|
||||
return
|
||||
}
|
||||
// Wait for the Android plugin to load and add the dependency to the plugin project.
|
||||
|
||||
Reference in New Issue
Block a user