Fix of flutter packages get in plugin project (#14757)
This commit is contained in:
parent
d4e973351e
commit
f526805e20
@ -56,15 +56,11 @@ class FlutterProject {
|
|||||||
/// Generates project files necessary to make Gradle builds work on Android
|
/// Generates project files necessary to make Gradle builds work on Android
|
||||||
/// and CocoaPods+Xcode work on iOS.
|
/// and CocoaPods+Xcode work on iOS.
|
||||||
void ensureReadyForPlatformSpecificTooling() {
|
void ensureReadyForPlatformSpecificTooling() {
|
||||||
if (!directory.existsSync()) {
|
if (!directory.existsSync() || isPluginProject) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isPluginProject) {
|
injectPlugins(directory: directory.path);
|
||||||
example.ensureReadyForPlatformSpecificTooling();
|
generateXcodeProperties(directory.path);
|
||||||
} else {
|
|
||||||
injectPlugins(directory: directory.path);
|
|
||||||
generateXcodeProperties(directory.path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +192,24 @@ void main() {
|
|||||||
// TODO(mravn): This test fails on the Chrome windows bot only.
|
// TODO(mravn): This test fails on the Chrome windows bot only.
|
||||||
// Skipping until resolved.
|
// Skipping until resolved.
|
||||||
}, timeout: allowForRemotePubInvocation, skip: true);
|
}, 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', () {
|
group('packages test/pub', () {
|
||||||
|
@ -23,6 +23,12 @@ void main() {
|
|||||||
project.ensureReadyForPlatformSpecificTooling();
|
project.ensureReadyForPlatformSpecificTooling();
|
||||||
expect(project.directory.existsSync(), isFalse);
|
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 {
|
testInMemory('injects plugins', () async {
|
||||||
final FlutterProject project = aProjectWithIos();
|
final FlutterProject project = aProjectWithIos();
|
||||||
project.ensureReadyForPlatformSpecificTooling();
|
project.ensureReadyForPlatformSpecificTooling();
|
||||||
@ -33,12 +39,6 @@ void main() {
|
|||||||
project.ensureReadyForPlatformSpecificTooling();
|
project.ensureReadyForPlatformSpecificTooling();
|
||||||
expect(project.ios.directory.childFile('Flutter/Generated.xcconfig').existsSync(), isTrue);
|
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', () {
|
group('organization names set', () {
|
||||||
testInMemory('is empty, if project not created', () async {
|
testInMemory('is empty, if project not created', () async {
|
||||||
|
@ -88,13 +88,15 @@ Matcher throwsProcessExit([dynamic exitCode]) {
|
|||||||
/// Matcher for [ProcessExit]s.
|
/// Matcher for [ProcessExit]s.
|
||||||
const Matcher isProcessExit = const isInstanceOf<ProcessExit>();
|
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.
|
/// 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 String projectPath = fs.path.join(temp.path, 'flutter_project');
|
||||||
final CreateCommand command = new CreateCommand();
|
final CreateCommand command = new CreateCommand();
|
||||||
final CommandRunner<Null> runner = createTestCommandRunner(command);
|
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;
|
return projectPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user