forked from firka/flutter
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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user