Skip to content

Commit

Permalink
Update prepare_for_embedded.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Jan 2, 2024
1 parent ffa890e commit 25df744
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkgs/cronet_http/tool/prepare_for_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const _packageDescription = 'An Android Flutter plugin that '
'provides access to the Cronet HTTP client. '
'Identical to package:cronet_http except that it embeds Cronet '
'rather than relying on Google Play Services.';
final implementationRegExp = RegExp(
'^\\s*implementation [\'"]'
'$_gmsDependencyName'
':\\d+.\\d+.\\d+[\'"]',
multiLine: true,
);

void main(List<String> args) async {
if (Directory.current.path.endsWith('tool')) {
Expand All @@ -48,6 +54,7 @@ void main(List<String> args) async {
}

updateCronetDependency(_cronetEmbeddedVersion);
update2();
updatePubSpec();
updateReadme();
updateLibraryName();
Expand All @@ -58,12 +65,6 @@ void main(List<String> args) async {
void updateCronetDependency(String latestVersion) {
final fBuildGradle = File('${_packageDirectory.path}/android/build.gradle');
final gradleContent = fBuildGradle.readAsStringSync();
final implementationRegExp = RegExp(
'^\\s*implementation [\'"]'
'$_gmsDependencyName'
':\\d+.\\d+.\\d+[\'"]',
multiLine: true,
);
final newImplementation = '$_embeddedDependencyName:$latestVersion';
print('Patching $newImplementation');
final newGradleContent = gradleContent.replaceAll(
Expand All @@ -73,6 +74,17 @@ void updateCronetDependency(String latestVersion) {
fBuildGradle.writeAsStringSync(newGradleContent);
}

void update2() {
final fBuildGradle =
File('${_packageDirectory.path}/example/android/app/build.gradle');
final gradleContent = fBuildGradle.readAsStringSync();
final newGradleContent = gradleContent.replaceAll(
implementationRegExp,
'',
);
fBuildGradle.writeAsStringSync(newGradleContent);
}

/// Update pubspec.yaml and example/pubspec.yaml.
void updatePubSpec() {
print('Updating pubspec.yaml');
Expand Down

0 comments on commit 25df744

Please sign in to comment.