Unverified Commit f264d6c2 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Allow plugins that don't support the Android platform (#46282)

parent 37384f25
...@@ -59,6 +59,43 @@ Future<void> main() async { ...@@ -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'); section('Write dummy Kotlin code in plugin B');
final File pluginBKotlinClass = File(path.join( final File pluginBKotlinClass = File(path.join(
...@@ -81,17 +118,19 @@ public class DummyPluginBClass { ...@@ -81,17 +118,19 @@ public class DummyPluginBClass {
} }
''', flush: true); ''', 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')); final File pluginApubspec = File(path.join(pluginADirectory.path, 'pubspec.yaml'));
String content = await pubspec.readAsString(); String pluginApubspecContent = await pluginApubspec.readAsString();
content = content.replaceFirst( pluginApubspecContent = pluginApubspecContent.replaceFirst(
'\ndependencies:\n', '\ndependencies:\n',
'\ndependencies:\n' '\ndependencies:\n'
' plugin_b:\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'); section('Write Kotlin code in plugin A that references Kotlin code from plugin B');
...@@ -142,11 +181,15 @@ public class DummyPluginAClass { ...@@ -142,11 +181,15 @@ public class DummyPluginAClass {
'\"dependencyGraph\":[' '\"dependencyGraph\":['
'{' '{'
'\"name\":\"plugin_a\",' '\"name\":\"plugin_a\",'
'\"dependencies\":[\"plugin_b\"]' '\"dependencies\":[\"plugin_b\",\"plugin_c\"]'
'},' '},'
'{' '{'
'\"name\":\"plugin_b\",' '\"name\":\"plugin_b\",'
'\"dependencies\":[]' '\"dependencies\":[]'
'},'
'{'
'\"name\":\"plugin_c\",'
'\"dependencies\":[]'
'}' '}'
']' ']'
'}'; '}';
......
...@@ -349,7 +349,7 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -349,7 +349,7 @@ class FlutterPlugin implements Plugin<Project> {
return return
} }
Project dependencyProject = project.rootProject.findProject(":$pluginDependencyName") Project dependencyProject = project.rootProject.findProject(":$pluginDependencyName")
if (dependencyProject == null) { if (!dependencyProject.projectDir.exists() || dependencyProject == null) {
return return
} }
// Wait for the Android plugin to load and add the dependency to the plugin project. // Wait for the Android plugin to load and add the dependency to the plugin project.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment