Migrate module templates to declarative application of the Flutter Gradle Plugin (#159770)
Fixes https://github.com/flutter/flutter/issues/159729 Cases to consider: 1. Building the module as a standalone app (`flutter run`) 2. Building the module as an aar (`flutter build aar`) 3. Doing (2) and then building an android host app that depends on the aar. 4. Building the host app with it depending on the module as source. Manually tested all 4 and they all are working. Modified `build_android_host_app_with_module_aar.dart` and `build_android_host_app_with_module_source.dart` to add checks on `stderr` to ensure we don't hit the log. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Gray Mackall <mackall@google.com>
This commit is contained in:
@@ -40,6 +40,8 @@ class ModuleTest {
|
||||
|
||||
static const String buildTarget = 'module-gradle';
|
||||
final String gradleVersion;
|
||||
final StringBuffer stdout = StringBuffer();
|
||||
final StringBuffer stderr = StringBuffer();
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
section('Running: $buildTarget-$gradleVersion');
|
||||
@@ -60,6 +62,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '--template=module', 'hello'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -68,6 +72,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'config',
|
||||
options: <String>['--enable-native-assets'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
|
||||
const String ffiPackageName = 'ffi_package';
|
||||
@@ -86,6 +92,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -126,6 +134,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -161,6 +171,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -181,7 +193,11 @@ class ModuleTest {
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter('clean');
|
||||
await flutter(
|
||||
'clean',
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
section('Make Android host app editable');
|
||||
@@ -190,6 +206,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'make-host-app-editable',
|
||||
options: <String>['android'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -199,6 +217,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -420,6 +440,12 @@ class ModuleTest {
|
||||
return TaskResult.failure('Failed to make assets user-readable and writable');
|
||||
}
|
||||
|
||||
section('Check for specific log errors.');
|
||||
final String finalStderr = stderr.toString();
|
||||
if (finalStderr.contains("You are applying Flutter's main Gradle plugin imperatively")) {
|
||||
return TaskResult.failure('Applied the Flutter Gradle Plugin imperatively');
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
|
||||
@@ -40,6 +40,8 @@ class ModuleTest {
|
||||
|
||||
static const String buildTarget = 'module-gradle';
|
||||
final String gradleVersion;
|
||||
final StringBuffer stdout = StringBuffer();
|
||||
final StringBuffer stderr = StringBuffer();
|
||||
|
||||
Future<TaskResult> call() async {
|
||||
section('Running: $buildTarget-$gradleVersion');
|
||||
@@ -60,6 +62,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'create',
|
||||
options: <String>['--org', 'io.flutter.devicelab', '--template=module', 'hello'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -68,6 +72,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'config',
|
||||
options: <String>['--enable-native-assets'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
|
||||
const String ffiPackageName = 'ffi_package';
|
||||
@@ -86,6 +92,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -126,6 +134,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'packages',
|
||||
options: <String>['get'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -135,6 +145,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -155,7 +167,11 @@ class ModuleTest {
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(projectDir, () async {
|
||||
await flutter('clean');
|
||||
await flutter(
|
||||
'clean',
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
section('Make Android host app editable');
|
||||
@@ -164,6 +180,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'make-host-app-editable',
|
||||
options: <String>['android'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -173,6 +191,8 @@ class ModuleTest {
|
||||
await flutter(
|
||||
'build',
|
||||
options: <String>['apk'],
|
||||
output: stdout,
|
||||
stderr: stderr,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -396,6 +416,12 @@ class ModuleTest {
|
||||
return TaskResult.failure('Failed to make assets user-readable and writable');
|
||||
}
|
||||
|
||||
section('Check for specific log errors.');
|
||||
final String finalStderr = stderr.toString();
|
||||
if (finalStderr.contains("You are applying Flutter's main Gradle plugin imperatively")) {
|
||||
return TaskResult.failure('Applied the Flutter Gradle Plugin imperatively');
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
return taskResult;
|
||||
|
||||
@@ -514,12 +514,21 @@ Future<int> flutter(String command, {
|
||||
// DevToolsMemoryTest in perf_tests.dart.
|
||||
Map<String, String>? environment,
|
||||
String? workingDirectory,
|
||||
StringBuffer? output, // if not null, the stdout will be written here
|
||||
StringBuffer? stderr, // if not null, the stderr will be written here
|
||||
}) async {
|
||||
final List<String> args = _flutterCommandArgs(
|
||||
command, options, driveWithDds: driveWithDds,
|
||||
);
|
||||
final int exitCode = await exec(path.join(flutterDirectory.path, 'bin', 'flutter'), args,
|
||||
canFail: canFail, environment: environment, workingDirectory: workingDirectory);
|
||||
final int exitCode = await exec(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
args,
|
||||
canFail: canFail,
|
||||
environment: environment,
|
||||
workingDirectory: workingDirectory,
|
||||
output: output,
|
||||
stderr: stderr,
|
||||
);
|
||||
|
||||
if (exitCode != 0 && !canFail) {
|
||||
await _flutterScreenshot(workingDirectory: workingDirectory);
|
||||
|
||||
Reference in New Issue
Block a user