Unverified Commit a467932d authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Skip plugins that don't have an android impl when building AARs (#46835)

parent 4944622b
......@@ -715,6 +715,10 @@ Future<void> buildPluginsAsAar(
assert(pluginDirectory.existsSync());
final String pluginName = pluginParts.first;
if (!pluginDirectory.childDirectory('android').existsSync()) {
printTrace('Skipping plugin $pluginName since it doesn\'t have an android directory');
continue;
}
logger.printStatus('Building plugin $pluginName...');
try {
await buildGradleAar(
......
......@@ -896,6 +896,9 @@ flutter:
plugin:
androidPackage: irrelevant
''');
plugin1.childDirectory('android').createSync();
final Directory plugin2 = fs.directory('plugin2.');
plugin2
..createSync()
......@@ -907,6 +910,8 @@ flutter:
androidPackage: irrelevant
''');
plugin2.childDirectory('android').createSync();
androidDirectory
.childFile('.flutter-plugins')
.writeAsStringSync('''
......@@ -927,8 +932,13 @@ plugin2=${plugin2.path}
);
final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
final String initScript = fs.path.join(flutterRoot, 'packages',
'flutter_tools', 'gradle', 'aar_init_script.gradle');
final String initScript = fs.path.join(
flutterRoot,
'packages',
'flutter_tools',
'gradle',
'aar_init_script.gradle',
);
verify(mockProcessManager.run(
<String>[
'gradlew',
......@@ -965,6 +975,70 @@ plugin2=${plugin2.path}
ProcessManager: () => mockProcessManager,
GradleUtils: () => FakeGradleUtils(),
});
testUsingContext('skips plugin without an android directory', () async {
final Directory androidDirectory = fs.directory('android.');
androidDirectory.createSync();
androidDirectory
.childFile('pubspec.yaml')
.writeAsStringSync('name: irrelevant');
final Directory plugin1 = fs.directory('plugin1.');
plugin1
..createSync()
..childFile('pubspec.yaml')
.writeAsStringSync('''
name: irrelevant
flutter:
plugin:
androidPackage: irrelevant
''');
androidDirectory
.childFile('.flutter-plugins')
.writeAsStringSync('''
plugin1=${plugin1.path}
''');
final Directory buildDirectory = androidDirectory.childDirectory('build');
buildDirectory
.childDirectory('outputs')
.childDirectory('repo')
.createSync(recursive: true);
await buildPluginsAsAar(
FlutterProject.fromPath(androidDirectory.path),
const AndroidBuildInfo(BuildInfo.release),
buildDirectory: buildDirectory,
);
final String flutterRoot = fs.path.absolute(Cache.flutterRoot);
final String initScript = fs.path.join(
flutterRoot,
'packages',
'flutter_tools',
'gradle',
'aar_init_script.gradle',
);
verifyNever(mockProcessManager.run(
<String>[
'gradlew',
'-I=$initScript',
'-Pflutter-root=$flutterRoot',
'-Poutput-dir=${buildDirectory.path}',
'-Pis-plugin=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleAarRelease',
],
environment: anyNamed('environment'),
workingDirectory: plugin1.childDirectory('android').path),
);
}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
FileSystem: () => fs,
ProcessManager: () => mockProcessManager,
GradleUtils: () => FakeGradleUtils(),
});
});
group('gradle build', () {
......
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