Unverified Commit bacaab97 authored by Stanislav Baranov's avatar Stanislav Baranov Committed by GitHub

Allow dynamic patches without a patch number. (#25796)

Unique patch numbers are mainly useful for canary and A-B testing, but otherwise complicate things and can now be omitted.
parent 52bd2ccb
...@@ -469,8 +469,14 @@ Future<void> _buildGradleProjectV2( ...@@ -469,8 +469,14 @@ Future<void> _buildGradleProjectV2(
update.addFile(ArchiveFile(name, newFile.content.length, newFile.content)); update.addFile(ArchiveFile(name, newFile.content.length, newFile.content));
} }
final File updateFile = fs.directory(buildInfo.patchDir) File updateFile;
if (buildInfo.patchNumber != null) {
updateFile = fs.directory(buildInfo.patchDir)
.childFile('${package.versionCode}-${buildInfo.patchNumber}.zip'); .childFile('${package.versionCode}-${buildInfo.patchNumber}.zip');
} else {
updateFile = fs.directory(buildInfo.patchDir)
.childFile('${package.versionCode}.zip');
}
if (update.files.isEmpty) { if (update.files.isEmpty) {
printStatus('No changes detected relative to baseline build.'); printStatus('No changes detected relative to baseline build.');
...@@ -490,9 +496,14 @@ Future<void> _buildGradleProjectV2( ...@@ -490,9 +496,14 @@ Future<void> _buildGradleProjectV2(
final Map<String, dynamic> manifest = <String, dynamic>{ final Map<String, dynamic> manifest = <String, dynamic>{
'baselineChecksum': baselineChecksum, 'baselineChecksum': baselineChecksum,
'buildNumber': package.versionCode, 'buildNumber': package.versionCode,
'patchNumber': buildInfo.patchNumber,
}; };
if (buildInfo.patchNumber != null) {
manifest.addAll(<String, dynamic>{
'patchNumber': buildInfo.patchNumber,
});
}
const JsonEncoder encoder = JsonEncoder.withIndent(' '); const JsonEncoder encoder = JsonEncoder.withIndent(' ');
final String manifestJson = encoder.convert(manifest); final String manifestJson = encoder.convert(manifest);
update.addFile(ArchiveFile('manifest.json', manifestJson.length, manifestJson.codeUnits)); update.addFile(ArchiveFile('manifest.json', manifestJson.length, manifestJson.codeUnits));
......
...@@ -54,7 +54,7 @@ class BuildInfo { ...@@ -54,7 +54,7 @@ class BuildInfo {
final bool createPatch; final bool createPatch;
/// Internal version number of dynamic patch (not displayed to users). /// Internal version number of dynamic patch (not displayed to users).
/// Each patch should have a unique number to differentiate from previous /// Each patch may have a unique number to differentiate from previous
/// patches for the same versionCode on Android or CFBundleVersion on iOS. /// patches for the same versionCode on Android or CFBundleVersion on iOS.
final int patchNumber; final int patchNumber;
......
...@@ -261,11 +261,13 @@ abstract class FlutterCommand extends Command<void> { ...@@ -261,11 +261,13 @@ abstract class FlutterCommand extends Command<void> {
void addDynamicPatchingFlags({bool verboseHelp = false}) { void addDynamicPatchingFlags({bool verboseHelp = false}) {
argParser.addOption('patch-number', argParser.addOption('patch-number',
defaultsTo: '1',
hide: !verboseHelp, hide: !verboseHelp,
help: 'An integer used as an internal version number for dynamic patch.\n' help: 'An integer used as an internal version number for dynamic patch.\n'
'Each update should have a unique number to differentiate from previous ' 'Each update may have a unique number to differentiate from previous\n'
'patches for same \'versionCode\' on Android or \'CFBundleVersion\' on iOS.\n' 'patches for same \'versionCode\' on Android or \'CFBundleVersion\' on iOS.\n'
'This optional setting allows several dynamic patches to coexist\n'
'for same baseline build, and is useful for canary and A-B testing\n'
'of dynamic patches.\n'
'This flag is only used when --dynamic --patch is specified.\n' 'This flag is only used when --dynamic --patch is specified.\n'
); );
argParser.addOption('patch-dir', argParser.addOption('patch-dir',
......
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