From 2dd8cb1ca281b55527f7aba3c39845be9f20c5d9 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 24 Jan 2022 22:28:38 -0500 Subject: [PATCH] Don't use example folder as a project type signal (#97157) The code to generate platform files used to use the presence of an 'example' folder to determine whether or not a project was a plugin (in which case that generation is bypassed). Later, robust detection was added based on the pubspec.yaml `plugin` key, but the old check was left in place. This creates false positives where people who add an example folder to their app project start getting mysterious failures. Since the pubspec check is definitive, there's no reason to continue to use the presence of `example` as an indicator at all. Fixes https://github.com/flutter/flutter/issues/87007 --- packages/flutter_tools/lib/src/project.dart | 2 +- .../test/general.shard/project_test.dart | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 166eb4767c..a1adda894c 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -310,7 +310,7 @@ class FlutterProject { bool winUwpPlatform = false, DeprecationBehavior deprecationBehavior = DeprecationBehavior.none, }) async { - if (!directory.existsSync() || hasExampleApp || isPlugin) { + if (!directory.existsSync() || isPlugin) { return; } await refreshPluginsList(this, iosPlatform: iosPlatform, macOSPlatform: macOSPlatform); diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart index 0214d3d847..ca2b583506 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart @@ -156,6 +156,18 @@ void main() { expectNotExists(project.ios.hostAppRoot.childDirectory('Flutter').childFile('Generated.xcconfig')); expectNotExists(project.android.hostAppGradleRoot.childFile('local.properties')); }); + _testInMemory('works if there is an "example" folder', () async { + final FlutterProject project = await someProject(); + // The presence of an "example" folder used to be used as an indicator + // that a project was a plugin, but shouldn't be as this creates false + // positives. + project.directory.childDirectory('example').createSync(); + await project.regeneratePlatformSpecificTooling(); + expectExists(project.ios.hostAppRoot.childDirectory('Runner').childFile('GeneratedPluginRegistrant.h')); + expectExists(androidPluginRegistrant(project.android.hostAppGradleRoot.childDirectory('app'))); + expectExists(project.ios.hostAppRoot.childDirectory('Flutter').childFile('Generated.xcconfig')); + expectExists(project.android.hostAppGradleRoot.childFile('local.properties')); + }); _testInMemory('injects plugins for iOS', () async { final FlutterProject project = await someProject(); await project.regeneratePlatformSpecificTooling();