diff --git a/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart b/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart index 16a6035147..e99376848e 100644 --- a/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart +++ b/dev/devicelab/bin/tasks/gradle_non_android_plugin_test.dart @@ -50,15 +50,20 @@ Future main() async { final String pubspecString = pubspecFile.readAsStringSync(); final StringBuffer iosOnlyPubspec = StringBuffer(); + bool inAndroidSection = false; + const String pluginPlatformIndentation = ' '; for (final String line in pubspecString.split('\n')) { - if (line.startsWith(' androidPackage:')) { + // Skip everything in the Android section of the plugin platforms list. + if (line.startsWith('${pluginPlatformIndentation}android:')) { + inAndroidSection = true; continue; } - if (line.startsWith(' pluginClass:')) { - iosOnlyPubspec.write(' platforms:\n'); - iosOnlyPubspec.write(' ios:\n'); - iosOnlyPubspec.write(' pluginClass: IosOnlyPlugin\n'); - continue; + if (inAndroidSection) { + if (line.startsWith('$pluginPlatformIndentation ')) { + continue; + } else { + inAndroidSection = false; + } } iosOnlyPubspec.write('$line\n'); } diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 71a3973317..095d1db876 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -642,10 +642,6 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi 'web': web, 'macos': macos, 'year': DateTime.now().year, - // For now, the new plugin schema is only used when a desktop plugin is - // enabled. Once the new schema is supported on stable, this should be - // removed, and the new schema should always be used. - 'useNewPluginSchema': macos, // If a desktop platform is included, add a workaround for #31366. // When Linux and Windows are added, we will need this workaround again. 'includeTargetPlatformWorkaround': false, diff --git a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl index 9408d34f11..9551c9c9c6 100644 --- a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl @@ -6,6 +6,7 @@ homepage: environment: sdk: ">=2.1.0 <3.0.0" + flutter: ">=1.10.0" dependencies: flutter: @@ -21,23 +22,9 @@ dev_dependencies: # The following section is specific to Flutter. flutter: # This section identifies this Flutter project as a plugin project. -{{^useNewPluginSchema}} - # The androidPackage and pluginClass identifiers should not ordinarily - # be modified. They are used by the tooling to maintain consistency when - # adding or updating assets for this project. - plugin: - androidPackage: {{androidIdentifier}} - pluginClass: {{pluginClass}} -{{/useNewPluginSchema}} -{{#useNewPluginSchema}} # The 'pluginClass' and Android 'package' identifiers should not ordinarily # be modified. They are used by the tooling to maintain consistency when # adding or updating assets for this project. - # - # NOTE: This new plugin description format is not supported on Flutter's - # stable channel as of 1.9.1. A plugin published using this format will not - # work for most clients until the next major stable release. - # However, it is required in order to declare macOS support. plugin: platforms: android: @@ -45,9 +32,10 @@ flutter: pluginClass: {{pluginClass}} ios: pluginClass: {{pluginClass}} +{{#macos}} macos: pluginClass: {{pluginClass}} -{{/useNewPluginSchema}} +{{/macos}} # To add assets to your plugin package, add an assets section, like this: # assets: diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index d80fdbf759..ed086f5453 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -645,6 +645,21 @@ void main() { FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false), }); + testUsingContext('plugin uses new platform schema', () async { + Cache.flutterRoot = '../..'; + when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); + when(mockFlutterVersion.channel).thenReturn(frameworkChannel); + + final CreateCommand command = CreateCommand(); + final CommandRunner runner = createTestCommandRunner(command); + + await runner.run(['create', '--no-pub', '--template=plugin', projectDir.path]); + + final String pubspecContents = await globals.fs.directory(projectDir.path).childFile('pubspec.yaml').readAsString(); + + expect(pubspecContents.contains('platforms:'), true); + }); + testUsingContext('has correct content and formatting with module template', () async { Cache.flutterRoot = '../..'; when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision);