Improves output file path logic in Android analyze (#136981)
This commit is contained in:
@@ -44,7 +44,9 @@ abstract class AndroidBuilder {
|
||||
Future<List<String>> getBuildVariants({required FlutterProject project});
|
||||
|
||||
/// Outputs app link related project settings into a json file.
|
||||
Future<void> outputsAppLinkSettings(
|
||||
///
|
||||
/// The return future resolves to the path of the json file.
|
||||
Future<String> outputsAppLinkSettings(
|
||||
String buildVariant, {
|
||||
required FlutterProject project,
|
||||
});
|
||||
|
||||
@@ -810,16 +810,22 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> outputsAppLinkSettings(
|
||||
Future<String> outputsAppLinkSettings(
|
||||
String buildVariant, {
|
||||
required FlutterProject project,
|
||||
}) async {
|
||||
final String taskName = _getOutputAppLinkSettingsTaskFor(buildVariant);
|
||||
final Directory directory = await project.buildDirectory
|
||||
.childDirectory('deeplink_data').create(recursive: true);
|
||||
final String outputPath = globals.fs.path.join(
|
||||
directory.absolute.path,
|
||||
'app-link-settings-$buildVariant.json',
|
||||
);
|
||||
final Stopwatch sw = Stopwatch()
|
||||
..start();
|
||||
final RunResult result = await _runGradleTask(
|
||||
taskName,
|
||||
options: const <String>['-q'],
|
||||
options: <String>['-q', '-PoutputPath=$outputPath'],
|
||||
project: project,
|
||||
);
|
||||
_usage.sendTiming('outputs', 'app link settings', sw.elapsed);
|
||||
@@ -827,7 +833,9 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
if (result.exitCode != 0) {
|
||||
_logger.printStatus(result.stdout, wrap: false);
|
||||
_logger.printError(result.stderr, wrap: false);
|
||||
throwToolExit(result.stderr);
|
||||
}
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ class AndroidAnalyze {
|
||||
logger.printStatus(jsonEncode(await project.android.getBuildVariants()));
|
||||
case AndroidAnalyzeOption.outputAppLinkSettings:
|
||||
assert(buildVariant != null);
|
||||
await project.android.outputsAppLinkSettings(variant: buildVariant!);
|
||||
final String filePath = fileSystem.path.join(project.directory.path, 'build', 'app', 'app-link-settings-$buildVariant.json`');
|
||||
final String filePath = await project.android.outputsAppLinkSettings(variant: buildVariant!);
|
||||
logger.printStatus('result saved in $filePath');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,13 +501,14 @@ class AndroidProject extends FlutterProjectPlatform {
|
||||
|
||||
/// Outputs app link related settings into a json file.
|
||||
///
|
||||
/// The file is stored in
|
||||
/// `<project>/build/app/app-link-settings-<variant>.json`.
|
||||
Future<void> outputsAppLinkSettings({required String variant}) async {
|
||||
/// The return future resolves to the path of the json file.
|
||||
///
|
||||
/// The future resolves to null if it fails to retrieve app link settings.
|
||||
Future<String> outputsAppLinkSettings({required String variant}) async {
|
||||
if (!existsSync() || androidBuilder == null) {
|
||||
return;
|
||||
throwToolExit('Target directory $hostAppGradleRoot is not an Android project');
|
||||
}
|
||||
await androidBuilder!.outputsAppLinkSettings(variant, project: parent);
|
||||
return androidBuilder!.outputsAppLinkSettings(variant, project: parent);
|
||||
}
|
||||
|
||||
bool _computeSupportedVersion() {
|
||||
|
||||
Reference in New Issue
Block a user