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