[flutter_tools] reland: --no-android-gradle-daemon in devicelab (#68491)
Remove devicelab specific code for shutting down gradle daemon, add --android-gradle-daemon option to build/run/drive`. Avoids need for un-tested devicelab specific handler. There are also some feature requests for this, so 2 birds one stone. Example: flutter build apk --no-android-gradle-daemon will pass --no-daemon on to gradle
This commit is contained in:
@@ -21,6 +21,7 @@ void main() {
|
||||
|
||||
await inDirectory(complexLayoutPath, () async {
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--profile',
|
||||
'--trace-startup', // Enables "endless" timeline event buffering.
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:vm_service_client/vm_service_client.dart';
|
||||
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
@@ -88,7 +87,6 @@ Future<TaskResult> runTask(
|
||||
} finally {
|
||||
if (!runnerFinished)
|
||||
runner.kill(ProcessSignal.sigkill);
|
||||
await cleanupSystem();
|
||||
await stdoutSub.cancel();
|
||||
await stderrSub.cancel();
|
||||
}
|
||||
@@ -124,42 +122,3 @@ Future<VMIsolateRef> _connectToRunnerIsolate(Uri vmServiceUri) async {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> cleanupSystem() async {
|
||||
if (deviceOperatingSystem == null || deviceOperatingSystem == DeviceOperatingSystem.android) {
|
||||
print('\n\nCleaning up system after task...');
|
||||
final String javaHome = await findJavaHome();
|
||||
if (javaHome != null) {
|
||||
// To shut gradle down, we have to call "gradlew --stop".
|
||||
// To call gradlew, we need to have a gradle-wrapper.properties file along
|
||||
// with a shell script, a .jar file, etc. We get these from various places
|
||||
// as you see in the code below, and we save them all into a temporary dir
|
||||
// which we can then delete after.
|
||||
// All the steps below are somewhat tolerant of errors, because it doesn't
|
||||
// really matter if this succeeds every time or not.
|
||||
print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)');
|
||||
final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.');
|
||||
recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
|
||||
copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
|
||||
if (!Platform.isWindows) {
|
||||
await exec(
|
||||
'chmod',
|
||||
<String>['a+x', path.join(tempDir.path, gradlewBinaryName)],
|
||||
canFail: true,
|
||||
);
|
||||
}
|
||||
await exec(
|
||||
path.join(tempDir.path, gradlewBinaryName),
|
||||
<String>['--stop'],
|
||||
environment: <String, String>{ 'JAVA_HOME': javaHome},
|
||||
workingDirectory: tempDir.path,
|
||||
canFail: true,
|
||||
);
|
||||
rmTree(tempDir);
|
||||
print('\n');
|
||||
} else {
|
||||
print('Could not determine JAVA_HOME; not shutting down Gradle.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ Future<TaskResult> runDartDefinesTask() async {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'--verbose',
|
||||
'-d',
|
||||
deviceId,
|
||||
|
||||
@@ -71,6 +71,7 @@ class GalleryTransitionTest {
|
||||
'build',
|
||||
options: <String>[
|
||||
'apk',
|
||||
'--no-android-gradle-daemon',
|
||||
'--profile',
|
||||
'-t',
|
||||
'test_driver/$testFile.dart',
|
||||
|
||||
@@ -26,7 +26,7 @@ TaskFunction createHotModeTest({String deviceIdOverride, Map<String, String> env
|
||||
final File benchmarkFile = file(path.join(_editedFlutterGalleryDir.path, 'hot_benchmark.json'));
|
||||
rm(benchmarkFile);
|
||||
final List<String> options = <String>[
|
||||
'--hot', '-d', deviceIdOverride, '--benchmark', '--verbose', '--resident',
|
||||
'--hot', '-d', deviceIdOverride, '--benchmark', '--verbose', '--resident', '--no-android-gradle-daemon',
|
||||
];
|
||||
int hotReloadCount = 0;
|
||||
Map<String, dynamic> twoReloadsData;
|
||||
|
||||
@@ -130,6 +130,7 @@ class DriverTest {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
final List<String> options = <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'-t',
|
||||
testTarget,
|
||||
|
||||
@@ -347,6 +347,7 @@ TaskFunction createsScrollSmoothnessPerfTest() {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--verbose-system-logs',
|
||||
'--profile',
|
||||
@@ -395,6 +396,7 @@ TaskFunction createFramePolicyIntegrationTest() {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--verbose-system-logs',
|
||||
'--profile',
|
||||
@@ -459,6 +461,7 @@ class StartupTest {
|
||||
final List<Map<String, dynamic>> results = <Map<String, dynamic>>[];
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
await flutter('run', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'--verbose',
|
||||
'--profile',
|
||||
'--trace-startup',
|
||||
@@ -575,6 +578,7 @@ class PerfTest {
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
await flutter('drive', options: <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
'-v',
|
||||
'--verbose-system-logs',
|
||||
'--profile',
|
||||
|
||||
@@ -43,6 +43,7 @@ class TrackWidgetCreationEnabledTask {
|
||||
final Process runProcess = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
flutterCommandArgs('run', <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
...?additionalArgs,
|
||||
'--vmservice-out-file=info',
|
||||
'--track-widget-creation',
|
||||
@@ -78,6 +79,7 @@ class TrackWidgetCreationEnabledTask {
|
||||
final Process runProcess = await startProcess(
|
||||
path.join(flutterDirectory.path, 'bin', 'flutter'),
|
||||
flutterCommandArgs('run', <String>[
|
||||
'--no-android-gradle-daemon',
|
||||
...?additionalArgs,
|
||||
'--vmservice-out-file=info',
|
||||
'--no-track-widget-creation',
|
||||
|
||||
Reference in New Issue
Block a user