Reland: Always use new plugin schema for plugin template (#49832)

Now that the new schema is supported on the stable channel, and the old
schema is considered legacy, the template should always create plugins
using the new schema.
This commit is contained in:
stuartmorgan
2020-02-27 22:48:25 -08:00
committed by GitHub
parent 9de7787f25
commit 33bb1faf5b
4 changed files with 29 additions and 25 deletions

View File

@@ -50,15 +50,20 @@ Future<void> 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');
}