FlutterProject refactoring and test coverage (#20296)

This commit is contained in:
Mikkel Nygaard Ravn
2018-08-07 23:43:15 +02:00
committed by GitHub
parent e60087a1a7
commit 3c83c52697
5 changed files with 266 additions and 143 deletions

View File

@@ -200,22 +200,26 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio
}
}
/// Overwrite android/local.properties in the specified Flutter project, if needed.
/// Overwrite local.properties in the specified Flutter project's Android
/// sub-project, if needed.
///
/// Throws, if `pubspec.yaml` or Android SDK cannot be located.
/// Throws tool exit, if `pubspec.yaml` is invalid.
///
/// If [requireSdk] is `true` this will fail with a tool-exit if no Android Sdk
/// If [requireSdk] is `true` this will fail with a tool exit if no Android Sdk
/// is found.
Future<void> updateLocalProperties({
@required FlutterProject project,
BuildInfo buildInfo,
bool requireAndroidSdk = true,
}) async {
if (project.manifest == null) {
throwToolExit('Invalid `pubspec.yaml`');
}
if (requireAndroidSdk && androidSdk == null) {
throwToolExit('Unable to locate Android SDK. Please run `flutter doctor` for more details.');
}
final File localProperties = project.androidLocalPropertiesFile;
final File localProperties = project.android.localPropertiesFile;
bool changed = false;
SettingsFile settings;