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

Fix of flutter packages get in plugin project (#14757)

parent d4e97335
......@@ -56,16 +56,12 @@ 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);
}
}
}
/// Represents the contents of the ios/ folder of a Flutter project.
......
......@@ -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: <String>['-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', () {
......
......@@ -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 {
......
......@@ -88,13 +88,15 @@ Matcher throwsProcessExit([dynamic exitCode]) {
/// Matcher for [ProcessExit]s.
const Matcher isProcessExit = const isInstanceOf<ProcessExit>();
/// 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<String> createProject(Directory temp) async {
Future<String> createProject(Directory temp, {List<String> arguments}) async {
arguments ??= <String>['--no-pub'];
final String projectPath = fs.path.join(temp.path, 'flutter_project');
final CreateCommand command = new CreateCommand();
final CommandRunner<Null> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', projectPath]);
await runner.run(<String>['create']..addAll(arguments)..add(projectPath));
return projectPath;
}
......
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