@@ -48,7 +48,7 @@ class FlutterExtension {
4848 * Specifies the relative directory to the Flutter project directory.
4949 * In an app project, this is ../.. since the app's build.gradle is under android/app.
5050 */
51- String source = ' ../.. '
51+ String source
5252
5353 /* * Allows to override the target file. Otherwise, the target is lib/main.dart. */
5454 String target
@@ -418,7 +418,7 @@ class FlutterPlugin implements Plugin<Project> {
418418
419419 /**
420420 * Compares semantic versions ignoring labels.
421- *
421+ *
422422 * If the versions are equal (ignoring labels), returns one of the two strings arbitrarily.
423423 *
424424 * If minor or patch are omitted (non-conformant to semantic versioning), they are considered zero.
@@ -459,9 +459,6 @@ class FlutterPlugin implements Plugin<Project> {
459459
460460 getPluginList(). each { plugin ->
461461 Project pluginProject = project. rootProject. findProject(plugin. key)
462- if (pluginProject == null ) {
463- return
464- }
465462 pluginProject. afterEvaluate {
466463 int pluginCompileSdkVersion = pluginProject. android. compileSdkVersion. substring(8 ) as int
467464 maxPluginCompileSdkVersion = Math . max(pluginCompileSdkVersion, maxPluginCompileSdkVersion)
@@ -479,7 +476,15 @@ class FlutterPlugin implements Plugin<Project> {
479476 }
480477 }
481478 }
482- }
479+ }
480+ }
481+
482+ /**
483+ * Returns `true` if the given path contains an `android/build.gradle` file.
484+ */
485+ private Boolean doesSupportAndroidPlatform (String path ) {
486+ File editableAndroidProject = new File (path, ' android' + File . separator + ' build.gradle' )
487+ return editableAndroidProject. exists()
483488 }
484489
485490 /**
@@ -490,7 +495,8 @@ class FlutterPlugin implements Plugin<Project> {
490495 private void configurePluginDependencies (Object dependencyObject ) {
491496 assert dependencyObject. name instanceof String
492497 Project pluginProject = project. rootProject. findProject(" :${ dependencyObject.name} " )
493- if (pluginProject == null ) {
498+ if (pluginProject == null ||
499+ ! doesSupportAndroidPlatform(pluginProject. projectDir. parentFile. path)) {
494500 return
495501 }
496502 assert dependencyObject. dependencies instanceof List
@@ -500,7 +506,8 @@ class FlutterPlugin implements Plugin<Project> {
500506 return
501507 }
502508 Project dependencyProject = project. rootProject. findProject(" :$pluginDependencyName " )
503- if (dependencyProject == null ) {
509+ if (dependencyProject == null ||
510+ ! doesSupportAndroidPlatform(dependencyProject. projectDir. parentFile. path)) {
504511 return
505512 }
506513 // Wait for the Android plugin to load and add the dependency to the plugin project.
@@ -512,27 +519,17 @@ class FlutterPlugin implements Plugin<Project> {
512519 }
513520 }
514521
515- /* * Gets the list of plugins that support the Android platform. */
516522 private Properties getPluginList () {
517- Map meta = getDependenciesMetadata()
523+ File pluginsFile = new File (project. projectDir. parentFile. parentFile, ' .flutter-plugins' )
524+ Properties allPlugins = readPropertiesIfExist(pluginsFile)
518525 Properties androidPlugins = new Properties ()
519- if (meta == null ) {
520- return androidPlugins
521- }
522- assert meta. plugins instanceof Map
523- assert meta. plugins. android instanceof List
524-
525- // This logic must be kept in sync with the logic in app_plugin_loader.gradle.
526- meta. plugins. android. each { androidPlugin ->
527- assert androidPlugin. name instanceof String
528- assert androidPlugin. path instanceof String
529- // Skip plugins that have no native build (such as a Dart-only implementation
530- // of a federated plugin).
531- def needsBuild = androidPlugin. containsKey(' native_build' ) ? androidPlugin[' native_build' ] : true
532- if (! needsBuild) {
533- return
526+ allPlugins. each { name , path ->
527+ if (doesSupportAndroidPlatform(path)) {
528+ androidPlugins. setProperty(name, path)
534529 }
535- androidPlugins. setProperty(androidPlugin. name, androidPlugin. path)
530+ // TODO(amirh): log an error if this plugin was specified to be an Android
531+ // plugin according to the new schema, and was missing a build.gradle file.
532+ // https://github.com/flutter/flutter/issues/40784
536533 }
537534 return androidPlugins
538535 }
@@ -560,31 +557,14 @@ class FlutterPlugin implements Plugin<Project> {
560557 // This means, `plugin-a` depends on `plugin-b` and `plugin-c`.
561558 // `plugin-b` depends on `plugin-c`.
562559 // `plugin-c` doesn't depend on anything.
563- Map meta = getDependenciesMetadata()
564- if (meta == null ) {
565- return []
566- }
567- assert meta. dependencyGraph instanceof List
568- return meta. dependencyGraph
569- }
570-
571- private Map parsedFlutterPluginsDependencies
572-
573- /**
574- * Parses <project-src>/.flutter-plugins-dependencies
575- */
576- private Map getDependenciesMetadata () {
577- if (parsedFlutterPluginsDependencies) {
578- return parsedFlutterPluginsDependencies
579- }
580- File pluginsDependencyFile = new File (getFlutterSourceDirectory(), ' .flutter-plugins-dependencies' )
560+ File pluginsDependencyFile = new File (project. projectDir. parentFile. parentFile, ' .flutter-plugins-dependencies' )
581561 if (pluginsDependencyFile. exists()) {
582562 def object = new JsonSlurper (). parseText(pluginsDependencyFile. text)
583563 assert object instanceof Map
584- parsedFlutterPluginsDependencies = object
585- return object
564+ assert object. dependencyGraph instanceof List
565+ return object. dependencyGraph
586566 }
587- return null
567+ return []
588568 }
589569
590570 private static String toCammelCase (List<String > parts ) {
0 commit comments