Unverified Commit 3c83c526 authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

FlutterProject refactoring and test coverage (#20296)

parent e60087a1
...@@ -200,22 +200,26 @@ distributionUrl=https\\://services.gradle.org/distributions/gradle-$gradleVersio ...@@ -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. /// is found.
Future<void> updateLocalProperties({ Future<void> updateLocalProperties({
@required FlutterProject project, @required FlutterProject project,
BuildInfo buildInfo, BuildInfo buildInfo,
bool requireAndroidSdk = true, bool requireAndroidSdk = true,
}) async { }) async {
if (project.manifest == null) {
throwToolExit('Invalid `pubspec.yaml`');
}
if (requireAndroidSdk && androidSdk == null) { if (requireAndroidSdk && androidSdk == null) {
throwToolExit('Unable to locate Android SDK. Please run `flutter doctor` for more details.'); 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; bool changed = false;
SettingsFile settings; SettingsFile settings;
......
...@@ -15,7 +15,6 @@ import '../base/process.dart'; ...@@ -15,7 +15,6 @@ import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../base/utils.dart'; import '../base/utils.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../bundle.dart' as bundle;
import '../cache.dart'; import '../cache.dart';
import '../flutter_manifest.dart'; import '../flutter_manifest.dart';
import '../globals.dart'; import '../globals.dart';
...@@ -28,25 +27,6 @@ String flutterFrameworkDir(BuildMode mode) { ...@@ -28,25 +27,6 @@ String flutterFrameworkDir(BuildMode mode) {
return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode))); return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode)));
} }
/// Writes default Xcode properties files in the Flutter project at [projectPath],
/// if project is an iOS project and such files are out of date or do not
/// already exist.
Future<void> generateXcodeProperties({FlutterProject project}) async {
if (project.manifest.isModule ||
project.ios.directory.existsSync()) {
if (!Cache.instance.fileOlderThanToolsStamp(project.generatedXcodePropertiesFile)) {
return;
}
await updateGeneratedXcodeProperties(
project: project,
buildInfo: BuildInfo.debug,
targetOverride: bundle.defaultMainPath,
previewDart2: true,
);
}
}
/// Writes or rewrites Xcode property files with the specified information. /// Writes or rewrites Xcode property files with the specified information.
/// ///
/// targetOverride: Optional parameter, if null or unspecified the default value /// targetOverride: Optional parameter, if null or unspecified the default value
...@@ -119,7 +99,7 @@ Future<void> updateGeneratedXcodeProperties({ ...@@ -119,7 +99,7 @@ Future<void> updateGeneratedXcodeProperties({
localsBuffer.writeln('TRACK_WIDGET_CREATION=true'); localsBuffer.writeln('TRACK_WIDGET_CREATION=true');
} }
final File generatedXcodePropertiesFile = project.generatedXcodePropertiesFile; final File generatedXcodePropertiesFile = project.ios.generatedXcodePropertiesFile;
generatedXcodePropertiesFile.createSync(recursive: true); generatedXcodePropertiesFile.createSync(recursive: true);
generatedXcodePropertiesFile.writeAsStringSync(localsBuffer.toString()); generatedXcodePropertiesFile.writeAsStringSync(localsBuffer.toString());
} }
......
...@@ -158,7 +158,7 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin> ...@@ -158,7 +158,7 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
}; };
final String javaSourcePath = fs.path.join( final String javaSourcePath = fs.path.join(
project.androidPluginRegistrantHost.path, project.android.pluginRegistrantHost.path,
'src', 'src',
'main', 'main',
'java', 'java',
...@@ -247,8 +247,8 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug ...@@ -247,8 +247,8 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
'plugins': iosPlugins, 'plugins': iosPlugins,
}; };
final String registryDirectory = project.iosPluginRegistrantHost.path; final String registryDirectory = project.ios.pluginRegistrantHost.path;
if (project.manifest.isModule) { if (project.isModule) {
final String registryClassesDirectory = fs.path.join(registryDirectory, 'Classes'); final String registryClassesDirectory = fs.path.join(registryDirectory, 'Classes');
_renderTemplateToFile( _renderTemplateToFile(
_iosPluginRegistrantPodspecTemplate, _iosPluginRegistrantPodspecTemplate,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment