Create configOnly flag for android (#121904)

Create configOnly flag for android
This commit is contained in:
Reid Baker
2023-03-08 14:46:52 -05:00
committed by GitHub
parent a9700ffdd5
commit fe9e819143
6 changed files with 109 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ abstract class AndroidBuilder {
required FlutterProject project,
required AndroidBuildInfo androidBuildInfo,
required String target,
bool configOnly = false,
});
/// Builds an App Bundle artifact.
@@ -36,5 +37,6 @@ abstract class AndroidBuilder {
required String target,
bool validateDeferredComponents = true,
bool deferredComponentsEnabled = false,
bool configOnly = false,
});
}

View File

@@ -181,6 +181,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required FlutterProject project,
required AndroidBuildInfo androidBuildInfo,
required String target,
bool configOnly = false,
}) async {
await buildGradleApp(
project: project,
@@ -188,6 +189,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
target: target,
isBuildingBundle: false,
localGradleErrors: gradleErrors,
configOnly: configOnly,
);
}
@@ -199,6 +201,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required String target,
bool validateDeferredComponents = true,
bool deferredComponentsEnabled = false,
bool configOnly = false,
}) async {
await buildGradleApp(
project: project,
@@ -208,6 +211,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
localGradleErrors: gradleErrors,
validateDeferredComponents: validateDeferredComponents,
deferredComponentsEnabled: deferredComponentsEnabled,
configOnly: configOnly,
);
}
@@ -225,6 +229,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
required String target,
required bool isBuildingBundle,
required List<GradleHandledError> localGradleErrors,
required bool configOnly,
bool validateDeferredComponents = true,
bool deferredComponentsEnabled = false,
int retry = 0,
@@ -249,8 +254,22 @@ class AndroidGradleBuilder implements AndroidBuilder {
}
// The default Gradle script reads the version name and number
// from the local.properties file.
updateLocalProperties(project: project, buildInfo: androidBuildInfo.buildInfo);
updateLocalProperties(
project: project, buildInfo: androidBuildInfo.buildInfo);
final List<String> command = <String>[
// This does more than get gradlewrapper. It creates the file, ensures it
// exists and verifies the file is executable.
_gradleUtils.getExecutable(project),
];
// All automatically created files should exist.
if (configOnly) {
_logger.printStatus('Config complete.');
return;
}
// Assembly work starts here.
final BuildInfo buildInfo = androidBuildInfo.buildInfo;
final String assembleTask = isBuildingBundle
? getBundleTaskFor(buildInfo)
@@ -260,9 +279,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
"Running Gradle task '$assembleTask'...",
);
final List<String> command = <String>[
_gradleUtils.getExecutable(project),
];
if (_logger.isVerbose) {
command.add('--full-stacktrace');
command.add('--info');
@@ -428,6 +444,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
localGradleErrors: localGradleErrors,
retry: retry,
maxRetries: maxRetries,
configOnly: configOnly,
);
final String successEventLabel = 'gradle-${detectedGradleError!.eventLabel}-success';
BuildEvent(successEventLabel, type: 'gradle', flutterUsage: _usage).send();

View File

@@ -43,6 +43,9 @@ class BuildApkCommand extends BuildSubCommand {
help: 'Whether to split the APKs per ABIs. '
'To learn more, see: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split',
)
..addFlag('config-only',
help: 'Generate build files used by flutter but '
'do not build any artifacts.')
..addMultiOption('target-platform',
defaultsTo: <String>['android-arm', 'android-arm64', 'android-x64'],
allowed: <String>['android-arm', 'android-arm64', 'android-x86', 'android-x64'],
@@ -57,6 +60,8 @@ class BuildApkCommand extends BuildSubCommand {
@override
DeprecationBehavior get deprecationBehavior => boolArgDeprecated('ignore-deprecation') ? DeprecationBehavior.ignore : DeprecationBehavior.exit;
bool get configOnly => boolArg('config-only') ?? false;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
DevelopmentArtifact.androidGenSnapshot,
@@ -112,6 +117,7 @@ class BuildApkCommand extends BuildSubCommand {
project: FlutterProject.current(),
target: targetFile,
androidBuildInfo: androidBuildInfo,
configOnly: configOnly,
);
return FlutterCommandResult.success();
}