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

Don't print how to consume AARs when building plugins as AARs (#44301)

parent 9492dcc7
......@@ -70,6 +70,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
androidBuildInfo: androidBuildInfo,
target: target,
outputDir: outputDirectory,
printHowToConsumeAaar: true,
);
} finally {
androidSdk.reinitialize();
......
......@@ -472,7 +472,14 @@ Future<void> buildGradleAar({
@required AndroidBuildInfo androidBuildInfo,
@required String target,
@required Directory outputDir,
@required bool printHowToConsumeAaar,
}) async {
assert(project != null);
assert(androidBuildInfo != null);
assert(target != null);
assert(outputDir != null);
assert(printHowToConsumeAaar != null);
if (androidSdk == null) {
exitWithNoSdkMessage();
}
......@@ -564,11 +571,13 @@ Future<void> buildGradleAar({
'$successMark Built ${fs.path.relative(repoDirectory.path)}.',
color: TerminalColor.green,
);
_printHowToConsumeAar(
buildMode: androidBuildInfo.buildInfo.modeName,
androidPackage: project.manifest.androidPackage,
repoPath: repoDirectory.path,
);
if (printHowToConsumeAaar) {
_printHowToConsumeAar(
buildMode: androidBuildInfo.buildInfo.modeName,
androidPackage: project.manifest.androidPackage,
repoPath: repoDirectory.path,
);
}
}
/// Prints how to consume the AAR from a host app.
......@@ -688,6 +697,7 @@ Future<void> buildPluginsAsAar(
),
target: '',
outputDir: buildDirectory,
printHowToConsumeAaar: false,
);
} on ToolExit {
// Log the entire plugin entry in `.flutter-plugins` since it
......
......@@ -1501,7 +1501,7 @@ plugin2=${plugin2.path}
ProcessManager: () => mockProcessManager,
});
testUsingContext('indicates how to consume an AAR', () async {
testUsingContext('indicates how to consume an AAR when printHowToConsumeAaar is true', () async {
final File manifestFile = fs.file('pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync('''
......@@ -1533,6 +1533,7 @@ plugin2=${plugin2.path}
project: FlutterProject.current(),
outputDir: fs.directory('build/'),
target: '',
printHowToConsumeAaar: true,
);
final BufferLogger logger = context.get<Logger>();
......@@ -1573,6 +1574,60 @@ To learn more, visit https://flutter.dev/go/build-aar'''));
ProcessManager: () => mockProcessManager,
});
testUsingContext('doesn\'t indicate how to consume an AAR when printHowToConsumeAaar is false', () async {
final File manifestFile = fs.file('pubspec.yaml');
manifestFile.createSync(recursive: true);
manifestFile.writeAsStringSync('''
flutter:
module:
androidPackage: com.example.test
'''
);
fs.file('.android/gradlew').createSync(recursive: true);
fs.file('.android/gradle.properties')
.writeAsStringSync('irrelevant');
fs.file('.android/build.gradle')
.createSync(recursive: true);
// Let any process start. Assert after.
when(mockProcessManager.run(
any,
environment: anyNamed('environment'),
workingDirectory: anyNamed('workingDirectory'),
)).thenAnswer((_) async => ProcessResult(1, 0, '', ''));
fs.directory('build/outputs/repo').createSync(recursive: true);
await buildGradleAar(
androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null)),
project: FlutterProject.current(),
outputDir: fs.directory('build/'),
target: '',
printHowToConsumeAaar: false,
);
final BufferLogger logger = context.get<Logger>();
expect(
logger.statusText,
contains('Built build/outputs/repo'),
);
expect(
logger.statusText.contains('Consuming the Module'),
isFalse,
);
}, overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
AndroidStudio: () => mockAndroidStudio,
Cache: () => cache,
Platform: () => android,
FileSystem: () => fs,
ProcessManager: () => mockProcessManager,
});
testUsingContext('build apk uses selected local engine', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine');
......@@ -1715,6 +1770,7 @@ To learn more, visit https://flutter.dev/go/build-aar'''));
project: FlutterProject.current(),
outputDir: fs.directory('build/'),
target: '',
printHowToConsumeAaar: false,
);
final List<String> actualGradlewCall = verify(
......
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