Clean up startProgress logic. (#19695) (#20009)

Disallow calling stop() or cancel() multiple times. This means that
when you use startProgress you have to more carefully think about what
exactly is going on.

Properly cancel startProgress in non-ANSI situations, so that
back-to-back startProgress calls all render to the console.
This commit is contained in:
Ian Hickson
2018-07-30 16:58:07 -07:00
committed by GitHub
parent ee396272d3
commit acf4b6c1aa
15 changed files with 261 additions and 243 deletions

View File

@@ -93,29 +93,34 @@ Future<GradleProject> _readGradleProject() async {
final FlutterProject flutterProject = new FlutterProject(fs.currentDirectory);
final String gradle = await _ensureGradle(flutterProject);
await updateLocalProperties(project: flutterProject);
final Status status = logger.startProgress('Resolving dependencies...', expectSlowOperation: true);
GradleProject project;
try {
final Status status = logger.startProgress('Resolving dependencies...', expectSlowOperation: true);
final RunResult runResult = await runCheckedAsync(
<String>[gradle, 'app:properties'],
workingDirectory: flutterProject.android.directory.path,
environment: _gradleEnv,
);
final String properties = runResult.stdout.trim();
final GradleProject project = new GradleProject.fromAppProperties(properties);
status.stop();
return project;
} catch (e) {
project = new GradleProject.fromAppProperties(properties);
} catch (exception) {
if (getFlutterPluginVersion(flutterProject.android) == FlutterPluginVersion.managed) {
status.cancel();
// Handle known exceptions. This will exit if handled.
handleKnownGradleExceptions(e);
handleKnownGradleExceptions(exception);
// Print a general Gradle error and exit.
printError('* Error running Gradle:\n$e\n');
printError('* Error running Gradle:\n$exception\n');
throwToolExit('Please review your Gradle project setup in the android/ folder.');
}
// Fall back to the default
project = new GradleProject(
<String>['debug', 'profile', 'release'],
<String>[], flutterProject.android.gradleAppOutV1Directory,
);
}
// Fall back to the default
return new GradleProject(<String>['debug', 'profile', 'release'], <String>[], flutterProject.android.gradleAppOutV1Directory);
status.stop();
return project;
}
void handleKnownGradleExceptions(String exceptionString) {