|
5 | 5 | // This file is included from `<module>/.android/include_flutter.groovy`,
|
6 | 6 | // so it can be versioned with the Flutter SDK.
|
7 | 7 |
|
8 |
| -import groovy.json.JsonSlurper |
| 8 | +import java.nio.file.Paths |
| 9 | + |
| 10 | +File pathToThisDirectory = buildscript.sourceFile.parentFile |
| 11 | +apply from: Paths.get(pathToThisDirectory.absolutePath, "src", "main", "groovy", "native_plugin_loader.groovy") |
9 | 12 |
|
10 | 13 | def moduleProjectRoot = project(':flutter').projectDir.parentFile.parentFile
|
11 | 14 |
|
12 |
| -def object = null; |
13 |
| -String flutterModulePath = project(':flutter').projectDir.parentFile.getAbsolutePath() |
14 |
| -// If this logic is changed, also change the logic in app_plugin_loader.gradle. |
15 |
| -def pluginsFile = new File(moduleProjectRoot, '.flutter-plugins-dependencies') |
16 |
| -if (pluginsFile.exists()) { |
17 |
| - object = new JsonSlurper().parseText(pluginsFile.text) |
18 |
| - assert object instanceof Map |
19 |
| - assert object.plugins instanceof Map |
20 |
| - assert object.plugins.android instanceof List |
21 |
| - // Includes the Flutter plugins that support the Android platform. |
22 |
| - object.plugins.android.each { androidPlugin -> |
23 |
| - assert androidPlugin.name instanceof String |
24 |
| - assert androidPlugin.path instanceof String |
25 |
| - // Skip plugins that have no native build (such as a Dart-only |
26 |
| - // implementation of a federated plugin). |
27 |
| - def needsBuild = androidPlugin.containsKey('native_build') ? androidPlugin['native_build'] : true |
28 |
| - if (!needsBuild) { |
29 |
| - return |
30 |
| - } |
31 |
| - def pluginDirectory = new File(androidPlugin.path, 'android') |
32 |
| - assert pluginDirectory.exists() |
33 |
| - include ":${androidPlugin.name}" |
34 |
| - project(":${androidPlugin.name}").projectDir = pluginDirectory |
35 |
| - } |
| 15 | +List<Map<String, Object>> nativePlugins = nativePluginLoader.getPlugins(moduleProjectRoot) |
| 16 | +nativePlugins.each { androidPlugin -> |
| 17 | + def pluginDirectory = new File(androidPlugin.path as String, 'android') |
| 18 | + assert pluginDirectory.exists() |
| 19 | + include ":${androidPlugin.name}" |
| 20 | + project(":${androidPlugin.name}").projectDir = pluginDirectory |
36 | 21 | }
|
37 | 22 |
|
| 23 | +String flutterModulePath = project(':flutter').projectDir.parentFile.getAbsolutePath() |
38 | 24 | gradle.getGradle().projectsLoaded { g ->
|
39 | 25 | g.rootProject.beforeEvaluate { p ->
|
40 | 26 | p.subprojects { subproject ->
|
41 |
| - if (object != null && object.plugins != null && object.plugins.android != null |
42 |
| - && object.plugins.android.name.contains(subproject.name)) { |
| 27 | + if (nativePlugins.name.contains(subproject.name)) { |
43 | 28 | File androidPluginBuildOutputDir = new File(flutterModulePath + File.separator
|
44 | 29 | + "plugins_build_output" + File.separator + subproject.name);
|
45 | 30 | if (!androidPluginBuildOutputDir.exists()) {
|
|
0 commit comments