Unverified Commit 18d5b9dc authored by matthew-carroll's avatar matthew-carroll Committed by GitHub

Renamed 'flutter materialize' to 'flutter make-host-app-editable'. The iOS...

Renamed 'flutter materialize' to 'flutter make-host-app-editable'. The iOS version is still incomplete and will therefore require additional renaming. (#21771) (#22006)
parent 3c22d7b0
...@@ -23,7 +23,7 @@ import 'src/commands/ide_config.dart'; ...@@ -23,7 +23,7 @@ import 'src/commands/ide_config.dart';
import 'src/commands/inject_plugins.dart'; import 'src/commands/inject_plugins.dart';
import 'src/commands/install.dart'; import 'src/commands/install.dart';
import 'src/commands/logs.dart'; import 'src/commands/logs.dart';
import 'src/commands/materialize.dart'; import 'src/commands/make_host_app_editable.dart';
import 'src/commands/packages.dart'; import 'src/commands/packages.dart';
import 'src/commands/precache.dart'; import 'src/commands/precache.dart';
import 'src/commands/run.dart'; import 'src/commands/run.dart';
...@@ -68,7 +68,7 @@ Future<Null> main(List<String> args) async { ...@@ -68,7 +68,7 @@ Future<Null> main(List<String> args) async {
InjectPluginsCommand(hidden: !verboseHelp), InjectPluginsCommand(hidden: !verboseHelp),
InstallCommand(), InstallCommand(),
LogsCommand(), LogsCommand(),
MaterializeCommand(), MakeHostAppEditableCommand(),
PackagesCommand(), PackagesCommand(),
PrecacheCommand(), PrecacheCommand(),
RunCommand(verboseHelp: verboseHelp), RunCommand(verboseHelp: verboseHelp),
......
...@@ -8,17 +8,17 @@ import '../base/common.dart'; ...@@ -8,17 +8,17 @@ import '../base/common.dart';
import '../project.dart'; import '../project.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
class MaterializeCommand extends FlutterCommand { class MakeHostAppEditableCommand extends FlutterCommand {
MaterializeCommand() { MakeHostAppEditableCommand() {
addSubcommand(MaterializeAndroidCommand()); addSubcommand(MakeHostAppEditableAndroidCommand());
addSubcommand(MaterializeIosCommand()); addSubcommand(MakeHostAppEditableIosCommand());
} }
@override @override
final String name = 'materialize'; final String name = 'make-host-app-editable';
@override @override
final String description = 'Commands for materializing host apps for a Flutter Module'; final String description = 'Commands for making host apps editable within a Flutter project';
@override @override
bool get hidden => true; bool get hidden => true;
...@@ -27,8 +27,8 @@ class MaterializeCommand extends FlutterCommand { ...@@ -27,8 +27,8 @@ class MaterializeCommand extends FlutterCommand {
Future<Null> runCommand() async { } Future<Null> runCommand() async { }
} }
abstract class MaterializeSubCommand extends FlutterCommand { abstract class MakeHostAppEditableSubCommand extends FlutterCommand {
MaterializeSubCommand() { MakeHostAppEditableSubCommand() {
requiresPubspecYaml(); requiresPubspecYaml();
} }
...@@ -45,34 +45,34 @@ abstract class MaterializeSubCommand extends FlutterCommand { ...@@ -45,34 +45,34 @@ abstract class MaterializeSubCommand extends FlutterCommand {
await super.validateCommand(); await super.validateCommand();
_project = await FlutterProject.current(); _project = await FlutterProject.current();
if (!_project.isModule) if (!_project.isModule)
throw ToolExit("Only projects created using 'flutter create -t module' can be materialized."); throw ToolExit("Only projects created using 'flutter create -t module' can have their host apps made editable.");
} }
} }
class MaterializeAndroidCommand extends MaterializeSubCommand { class MakeHostAppEditableAndroidCommand extends MakeHostAppEditableSubCommand {
@override @override
String get name => 'android'; String get name => 'android';
@override @override
String get description => 'Materialize an Android host app'; String get description => 'Make an Android host app editable within a Flutter project';
@override @override
Future<Null> runCommand() async { Future<Null> runCommand() async {
await super.runCommand(); await super.runCommand();
await _project.android.materialize(); await _project.android.makeHostAppEditable();
} }
} }
class MaterializeIosCommand extends MaterializeSubCommand { class MakeHostAppEditableIosCommand extends MakeHostAppEditableSubCommand {
@override @override
String get name => 'ios'; String get name => 'ios';
@override @override
String get description => 'Materialize an iOS host app'; String get description => 'Make an iOS host app editable within a Flutter project';
@override @override
Future<Null> runCommand() async { Future<Null> runCommand() async {
await super.runCommand(); await super.runCommand();
await _project.ios.materialize(); await _project.ios.makeHostAppEditable();
} }
} }
...@@ -258,8 +258,8 @@ class IosProject { ...@@ -258,8 +258,8 @@ class IosProject {
} }
} }
Future<void> materialize() async { Future<void> makeHostAppEditable() async {
throwToolExit('flutter materialize has not yet been implemented for iOS'); throwToolExit('making host app editable has not yet been implemented for iOS');
} }
File get generatedXcodePropertiesFile => directory.childDirectory('Flutter').childFile('Generated.xcconfig'); File get generatedXcodePropertiesFile => directory.childDirectory('Flutter').childFile('Generated.xcconfig');
...@@ -301,18 +301,18 @@ class AndroidProject { ...@@ -301,18 +301,18 @@ class AndroidProject {
/// containing the `app/` subdirectory and the `settings.gradle` file that /// containing the `app/` subdirectory and the `settings.gradle` file that
/// includes it in the overall Gradle project. /// includes it in the overall Gradle project.
Directory get hostAppGradleRoot { Directory get hostAppGradleRoot {
if (!isModule || _materializedDirectory.existsSync()) if (!isModule || _editableHostAppDirectory.existsSync())
return _materializedDirectory; return _editableHostAppDirectory;
return _ephemeralDirectory; return _ephemeralDirectory;
} }
/// The Gradle root directory of the Android wrapping of Flutter and plugins. /// The Gradle root directory of the Android wrapping of Flutter and plugins.
/// This is the same as [hostAppGradleRoot] except when the project is /// This is the same as [hostAppGradleRoot] except when the project is
/// a Flutter module with a materialized host app. /// a Flutter module with an editable host app.
Directory get _flutterLibGradleRoot => isModule ? _ephemeralDirectory : _materializedDirectory; Directory get _flutterLibGradleRoot => isModule ? _ephemeralDirectory : _editableHostAppDirectory;
Directory get _ephemeralDirectory => parent.directory.childDirectory('.android'); Directory get _ephemeralDirectory => parent.directory.childDirectory('.android');
Directory get _materializedDirectory => parent.directory.childDirectory('android'); Directory get _editableHostAppDirectory => parent.directory.childDirectory('android');
/// True, if the parent Flutter project is a module. /// True, if the parent Flutter project is a module.
bool get isModule => parent.isModule; bool get isModule => parent.isModule;
...@@ -346,8 +346,8 @@ class AndroidProject { ...@@ -346,8 +346,8 @@ class AndroidProject {
Future<void> ensureReadyForPlatformSpecificTooling() async { Future<void> ensureReadyForPlatformSpecificTooling() async {
if (isModule && _shouldRegenerateFromTemplate()) { if (isModule && _shouldRegenerateFromTemplate()) {
_regenerateLibrary(); _regenerateLibrary();
// Add ephemeral host app, if a materialized host app does not already exist. // Add ephemeral host app, if an editable host app does not already exist.
if (!_materializedDirectory.existsSync()) { if (!_editableHostAppDirectory.existsSync()) {
_overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _ephemeralDirectory); _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _ephemeralDirectory);
_overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_ephemeral'), _ephemeralDirectory); _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_ephemeral'), _ephemeralDirectory);
} }
...@@ -363,16 +363,16 @@ class AndroidProject { ...@@ -363,16 +363,16 @@ class AndroidProject {
|| Cache.instance.isOlderThanToolsStamp(_ephemeralDirectory); || Cache.instance.isOlderThanToolsStamp(_ephemeralDirectory);
} }
Future<void> materialize() async { Future<void> makeHostAppEditable() async {
assert(isModule); assert(isModule);
if (_materializedDirectory.existsSync()) if (_editableHostAppDirectory.existsSync())
throwToolExit('Android host app already materialized. To redo materialization, delete the android/ folder.'); throwToolExit('Android host app is already editable. To start fresh, delete the android/ folder.');
_regenerateLibrary(); _regenerateLibrary();
_overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _materializedDirectory); _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_common'), _editableHostAppDirectory);
_overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_materialized'), _materializedDirectory); _overwriteFromTemplate(fs.path.join('module', 'android', 'host_app_editable'), _editableHostAppDirectory);
_overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), _materializedDirectory); _overwriteFromTemplate(fs.path.join('module', 'android', 'gradle'), _editableHostAppDirectory);
gradle.injectGradleWrapper(_materializedDirectory); gradle.injectGradleWrapper(_editableHostAppDirectory);
gradle.writeLocalProperties(_materializedDirectory.childFile('local.properties')); gradle.writeLocalProperties(_editableHostAppDirectory.childFile('local.properties'));
await injectPlugins(parent); await injectPlugins(parent);
} }
......
...@@ -37,7 +37,7 @@ with a dependency on the `.android/Flutter` library. ...@@ -37,7 +37,7 @@ with a dependency on the `.android/Flutter` library.
Executing `./gradlew app:assembleDebug` in the target folder produces Executing `./gradlew app:assembleDebug` in the target folder produces
an `.apk` archive. an `.apk` archive.
Used with either `android_host_ephemeral` or `android_host_materialized`. Used with either `android_host_ephemeral` or `android_host_editable`.
#### host_app_ephemeral #### host_app_ephemeral
...@@ -47,11 +47,11 @@ Combined contents define an *ephemeral* (hidden, auto-generated, ...@@ -47,11 +47,11 @@ Combined contents define an *ephemeral* (hidden, auto-generated,
under Flutter tooling control) Android host app with a dependency on the under Flutter tooling control) Android host app with a dependency on the
`.android/Flutter` library. `.android/Flutter` library.
#### host_app_materialized #### host_app_editable
Written to `android/` on top of `android_host_common`. Written to `android/` on top of `android_host_common`.
Combined contents define a *materialized* (visible, one-time generated, Combined contents define an *editable* (visible, one-time generated,
under app author control) Android host app with a dependency on the under app author control) Android host app with a dependency on the
`.android/Flutter` library. `.android/Flutter` library.
......
...@@ -89,22 +89,22 @@ void main() { ...@@ -89,22 +89,22 @@ void main() {
}); });
}); });
group('materialize Android', () { group('editable Android host app', () {
testInMemory('fails on non-module', () async { testInMemory('fails on non-module', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject();
await expectLater( await expectLater(
project.android.materialize(), project.android.makeHostAppEditable(),
throwsA(isInstanceOf<AssertionError>()), throwsA(isInstanceOf<AssertionError>()),
); );
}); });
testInMemory('exits on already materialized module', () async { testInMemory('exits on already editable module', () async {
final FlutterProject project = await aModuleProject(); final FlutterProject project = await aModuleProject();
await project.android.materialize(); await project.android.makeHostAppEditable();
return expectToolExitLater(project.android.materialize(), contains('already materialized')); return expectToolExitLater(project.android.makeHostAppEditable(), contains('already editable'));
}); });
testInMemory('creates android/app folder in place of .android/app', () async { testInMemory('creates android/app folder in place of .android/app', () async {
final FlutterProject project = await aModuleProject(); final FlutterProject project = await aModuleProject();
await project.android.materialize(); await project.android.makeHostAppEditable();
expectNotExists(project.directory.childDirectory('.android').childDirectory('app')); expectNotExists(project.directory.childDirectory('.android').childDirectory('app'));
expect( expect(
project.directory.childDirectory('.android').childFile('settings.gradle').readAsStringSync(), project.directory.childDirectory('.android').childFile('settings.gradle').readAsStringSync(),
...@@ -119,7 +119,7 @@ void main() { ...@@ -119,7 +119,7 @@ void main() {
}); });
testInMemory('retains .android/Flutter folder and references it', () async { testInMemory('retains .android/Flutter folder and references it', () async {
final FlutterProject project = await aModuleProject(); final FlutterProject project = await aModuleProject();
await project.android.materialize(); await project.android.makeHostAppEditable();
expectExists(project.directory.childDirectory('.android').childDirectory('Flutter')); expectExists(project.directory.childDirectory('.android').childDirectory('Flutter'));
expect( expect(
project.directory.childDirectory('android').childFile('settings.gradle').readAsStringSync(), project.directory.childDirectory('android').childFile('settings.gradle').readAsStringSync(),
...@@ -128,9 +128,9 @@ void main() { ...@@ -128,9 +128,9 @@ void main() {
}); });
testInMemory('can be redone after deletion', () async { testInMemory('can be redone after deletion', () async {
final FlutterProject project = await aModuleProject(); final FlutterProject project = await aModuleProject();
await project.android.materialize(); await project.android.makeHostAppEditable();
project.directory.childDirectory('android').deleteSync(recursive: true); project.directory.childDirectory('android').deleteSync(recursive: true);
await project.android.materialize(); await project.android.makeHostAppEditable();
expectExists(project.directory.childDirectory('android').childDirectory('app')); expectExists(project.directory.childDirectory('android').childDirectory('app'));
}); });
}); });
......
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