diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 7800f2a3e4..5a4da6bce1 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -56,15 +56,11 @@ class FlutterProject { /// Generates project files necessary to make Gradle builds work on Android /// and CocoaPods+Xcode work on iOS. void ensureReadyForPlatformSpecificTooling() { - if (!directory.existsSync()) { + if (!directory.existsSync() || isPluginProject) { return; } - if (isPluginProject) { - example.ensureReadyForPlatformSpecificTooling(); - } else { - injectPlugins(directory: directory.path); - generateXcodeProperties(directory.path); - } + injectPlugins(directory: directory.path); + generateXcodeProperties(directory.path); } } diff --git a/packages/flutter_tools/test/commands/packages_test.dart b/packages/flutter_tools/test/commands/packages_test.dart index e7fca648b8..e873acac22 100644 --- a/packages/flutter_tools/test/commands/packages_test.dart +++ b/packages/flutter_tools/test/commands/packages_test.dart @@ -192,6 +192,24 @@ void main() { // TODO(mravn): This test fails on the Chrome windows bot only. // Skipping until resolved. }, timeout: allowForRemotePubInvocation, skip: true); + testUsingContext('get fetches packages and injects plugin in plugin project', () async { + final String projectPath = await createProject( + temp, + arguments: ['-t', 'plugin', '--no-pub'], + ); + final String exampleProjectPath = fs.path.join(projectPath, 'example'); + removeGeneratedFiles(projectPath); + removeGeneratedFiles(exampleProjectPath); + + await runCommandIn(projectPath, 'get'); + + expectDependenciesResolved(projectPath); + + await runCommandIn(exampleProjectPath, 'get'); + + expectDependenciesResolved(exampleProjectPath); + expectPluginInjected(exampleProjectPath); + }, timeout: allowForRemotePubInvocation); }); group('packages test/pub', () { diff --git a/packages/flutter_tools/test/project_test.dart b/packages/flutter_tools/test/project_test.dart index 6ef5bbbee7..00aad68009 100644 --- a/packages/flutter_tools/test/project_test.dart +++ b/packages/flutter_tools/test/project_test.dart @@ -23,6 +23,12 @@ void main() { project.ensureReadyForPlatformSpecificTooling(); expect(project.directory.existsSync(), isFalse); }); + testInMemory('does nothing in plugin root project', () async { + final FlutterProject project = aPluginProject(); + project.ensureReadyForPlatformSpecificTooling(); + expect(project.example.ios.directory.childFile('Runner/GeneratedPluginRegistrant.h').existsSync(), isFalse); + expect(project.example.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isFalse); + }); testInMemory('injects plugins', () async { final FlutterProject project = aProjectWithIos(); project.ensureReadyForPlatformSpecificTooling(); @@ -33,12 +39,6 @@ void main() { project.ensureReadyForPlatformSpecificTooling(); expect(project.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isTrue); }); - testInMemory('generates files in plugin example project', () async { - final FlutterProject project = aPluginProject(); - project.ensureReadyForPlatformSpecificTooling(); - expect(project.example.ios.directory.childFile('Runner/GeneratedPluginRegistrant.h').existsSync(), isTrue); - expect(project.example.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isTrue); - }); }); group('organization names set', () { testInMemory('is empty, if project not created', () async { diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index 996269f5db..72f1b48fe8 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -88,13 +88,15 @@ Matcher throwsProcessExit([dynamic exitCode]) { /// Matcher for [ProcessExit]s. const Matcher isProcessExit = const isInstanceOf(); -/// Creates a flutter project in the [temp] directory. +/// Creates a flutter project in the [temp] directory using the +/// [arguments] list if specified, or `--no-pub` if not. /// Returns the path to the flutter project. -Future createProject(Directory temp) async { +Future createProject(Directory temp, {List arguments}) async { + arguments ??= ['--no-pub']; final String projectPath = fs.path.join(temp.path, 'flutter_project'); final CreateCommand command = new CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); - await runner.run(['create', '--no-pub', projectPath]); + await runner.run(['create']..addAll(arguments)..add(projectPath)); return projectPath; }