Skip to content

Commit f526805

Browse files
authored
Fix of flutter packages get in plugin project (flutter#14757)
1 parent d4e9733 commit f526805

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

packages/flutter_tools/lib/src/project.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ class FlutterProject {
5656
/// Generates project files necessary to make Gradle builds work on Android
5757
/// and CocoaPods+Xcode work on iOS.
5858
void ensureReadyForPlatformSpecificTooling() {
59-
if (!directory.existsSync()) {
59+
if (!directory.existsSync() || isPluginProject) {
6060
return;
6161
}
62-
if (isPluginProject) {
63-
example.ensureReadyForPlatformSpecificTooling();
64-
} else {
65-
injectPlugins(directory: directory.path);
66-
generateXcodeProperties(directory.path);
67-
}
62+
injectPlugins(directory: directory.path);
63+
generateXcodeProperties(directory.path);
6864
}
6965
}
7066

packages/flutter_tools/test/commands/packages_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,24 @@ void main() {
192192
// TODO(mravn): This test fails on the Chrome windows bot only.
193193
// Skipping until resolved.
194194
}, timeout: allowForRemotePubInvocation, skip: true);
195+
testUsingContext('get fetches packages and injects plugin in plugin project', () async {
196+
final String projectPath = await createProject(
197+
temp,
198+
arguments: <String>['-t', 'plugin', '--no-pub'],
199+
);
200+
final String exampleProjectPath = fs.path.join(projectPath, 'example');
201+
removeGeneratedFiles(projectPath);
202+
removeGeneratedFiles(exampleProjectPath);
203+
204+
await runCommandIn(projectPath, 'get');
205+
206+
expectDependenciesResolved(projectPath);
207+
208+
await runCommandIn(exampleProjectPath, 'get');
209+
210+
expectDependenciesResolved(exampleProjectPath);
211+
expectPluginInjected(exampleProjectPath);
212+
}, timeout: allowForRemotePubInvocation);
195213
});
196214

197215
group('packages test/pub', () {

packages/flutter_tools/test/project_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ void main() {
2323
project.ensureReadyForPlatformSpecificTooling();
2424
expect(project.directory.existsSync(), isFalse);
2525
});
26+
testInMemory('does nothing in plugin root project', () async {
27+
final FlutterProject project = aPluginProject();
28+
project.ensureReadyForPlatformSpecificTooling();
29+
expect(project.example.ios.directory.childFile('Runner/GeneratedPluginRegistrant.h').existsSync(), isFalse);
30+
expect(project.example.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isFalse);
31+
});
2632
testInMemory('injects plugins', () async {
2733
final FlutterProject project = aProjectWithIos();
2834
project.ensureReadyForPlatformSpecificTooling();
@@ -33,12 +39,6 @@ void main() {
3339
project.ensureReadyForPlatformSpecificTooling();
3440
expect(project.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isTrue);
3541
});
36-
testInMemory('generates files in plugin example project', () async {
37-
final FlutterProject project = aPluginProject();
38-
project.ensureReadyForPlatformSpecificTooling();
39-
expect(project.example.ios.directory.childFile('Runner/GeneratedPluginRegistrant.h').existsSync(), isTrue);
40-
expect(project.example.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isTrue);
41-
});
4242
});
4343
group('organization names set', () {
4444
testInMemory('is empty, if project not created', () async {

packages/flutter_tools/test/src/common.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ Matcher throwsProcessExit([dynamic exitCode]) {
8888
/// Matcher for [ProcessExit]s.
8989
const Matcher isProcessExit = const isInstanceOf<ProcessExit>();
9090

91-
/// Creates a flutter project in the [temp] directory.
91+
/// Creates a flutter project in the [temp] directory using the
92+
/// [arguments] list if specified, or `--no-pub` if not.
9293
/// Returns the path to the flutter project.
93-
Future<String> createProject(Directory temp) async {
94+
Future<String> createProject(Directory temp, {List<String> arguments}) async {
95+
arguments ??= <String>['--no-pub'];
9496
final String projectPath = fs.path.join(temp.path, 'flutter_project');
9597
final CreateCommand command = new CreateCommand();
9698
final CommandRunner<Null> runner = createTestCommandRunner(command);
97-
await runner.run(<String>['create', '--no-pub', projectPath]);
99+
await runner.run(<String>['create']..addAll(arguments)..add(projectPath));
98100
return projectPath;
99101
}
100102

0 commit comments

Comments
 (0)