Allow flavors and build types when using plugins (#71738)
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:flutter_devicelab/framework/apk_utils.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/task_result.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
@@ -207,6 +208,35 @@ Future<void> main() async {
|
||||
await project.runGradleTask('assembleLocal');
|
||||
});
|
||||
|
||||
await runProjectTest((FlutterProject project) async {
|
||||
section('gradlew assembleLocal with plugin (custom debug build)');
|
||||
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_plugin.');
|
||||
final Directory pluginDir = Directory(path.join(tempDir.path, 'plugin_under_test'));
|
||||
|
||||
section('Create plugin');
|
||||
await inDirectory(tempDir, () async {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>[
|
||||
'--org',
|
||||
'io.flutter.devicelab.plugin',
|
||||
'--template=plugin',
|
||||
'--platforms=android,ios',
|
||||
pluginDir.path,
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
section('Configure');
|
||||
project.addPlugin('plugin_under_test', value: '$platformLineSep path: ${pluginDir.path}');
|
||||
await project.addCustomBuildType('local', initWith: 'debug');
|
||||
await project.getPackages();
|
||||
|
||||
section('Build APK');
|
||||
await project.runGradleTask('assembleLocal');
|
||||
});
|
||||
|
||||
await runProjectTest((FlutterProject project) async {
|
||||
section('gradlew assembleBeta (custom release build)');
|
||||
await project.addCustomBuildType('beta', initWith: 'release');
|
||||
|
||||
@@ -280,12 +280,15 @@ subprojects {
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> addPlugin(String plugin) async {
|
||||
/// Adds a plugin to the pubspec.
|
||||
/// In pubspec, each dependency is expressed as key, value pair joined by a colon `:`.
|
||||
/// such as `plugin_a`:`^0.0.1` or `plugin_a`:`\npath: /some/path`.
|
||||
Future<void> addPlugin(String plugin, { String value = '' }) async {
|
||||
final File pubspec = File(path.join(rootPath, 'pubspec.yaml'));
|
||||
String content = await pubspec.readAsString();
|
||||
content = content.replaceFirst(
|
||||
'${platformLineSep}dependencies:$platformLineSep',
|
||||
'${platformLineSep}dependencies:$platformLineSep $plugin:$platformLineSep',
|
||||
'${platformLineSep}dependencies:$platformLineSep $plugin:$value$platformLineSep',
|
||||
);
|
||||
await pubspec.writeAsString(content, flush: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user