Don't import plugins that don't support android in settings.gradle (#54407)

This commit is contained in:
Emmanuel Garcia
2020-04-12 08:55:03 -07:00
committed by GitHub
parent 1118d24794
commit 54dba4cd59
49 changed files with 595 additions and 392 deletions

View File

@@ -0,0 +1,57 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path;
/// Tests that apps can be built using the deprecated `android/settings.gradle` file.
/// This test should be removed once apps have been migrated to this new file.
// TODO(egarciad): Migrate existing files, https://github.com/flutter/flutter/issues/54566
Future<void> main() async {
await task(() async {
section('Find Java');
final String javaHome = await findJavaHome();
if (javaHome == null)
return TaskResult.failure('Could not find Java');
print('\nUsing JAVA_HOME=$javaHome');
final Directory projectDirectory =
dir('${flutterDirectory.path}/dev/integration_tests/gradle_deprecated_settings');
try {
section('Build debug APK using deprecated settings.gradle');
await inDirectory(projectDirectory, () async {
await flutter(
'build',
options: <String>[
'apk',
'--debug',
'--target-platform', 'android-arm',
'--no-shrink',
'--verbose',
],
);
});
final File debugApk = File(path.join(
projectDirectory.path,
'build',
'app',
'outputs',
'flutter-apk',
'app-debug.apk',
));
if (!exists(debugApk)) {
return TaskResult.failure('Failed to build debug APK.');
}
return TaskResult.success(null);
} catch (e) {
return TaskResult.failure(e.toString());
}
});
}

View File

@@ -117,7 +117,7 @@ plugins.each { name, path ->
section('Override settings.gradle with custom logic');
const String customDeprecatedFileContent = '''
const String customDeprecatedFileContent = r'''
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
@@ -130,8 +130,8 @@ if (pluginsFile.exists()) {
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":\$name"
project(":\$name").projectDir = pluginDirectory
include ":$name"
project(":$name").projectDir = pluginDirectory
}
// some custom logic
''';