From 5013f68093111c23dbdbd161d364053d2627fa44 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 13:36:12 -0800 Subject: [PATCH 1/6] Remove 'com.google.android.gms:play-services-cronet' from package:cronet_http_embedded --- .../tool/prepare_for_embedded.dart | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 3442bc6843..58ba47890c 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -42,6 +42,12 @@ final _cronetVersionUri = Uri.https( 'dl.google.com', 'android/maven2/org/chromium/net/group-index.xml', ); +final implementationRegExp = RegExp( + '^\\s*implementation [\'"]' + '$_gmsDependencyName' + ':\\d+.\\d+.\\d+[\'"]', + multiLine: true, +); void main(List args) async { if (Directory.current.path.endsWith('tool')) { @@ -51,7 +57,8 @@ void main(List args) async { } final latestVersion = await _getLatestCronetVersion(); - updateCronetDependency(latestVersion); + updateBuildGradle(latestVersion); + updateExampleBuildGradle(); updatePubSpec(); updateReadme(); updateLibraryName(); @@ -75,22 +82,29 @@ Future _getLatestCronetVersion() async { } /// Update android/build.gradle. -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, - ); +void updateBuildGradle(String latestVersion) { + final buildGradle = File('${_packageDirectory.path}/android/build.gradle'); + final gradleContent = buildGradle.readAsStringSync(); final newImplementation = '$_embeddedDependencyName:$latestVersion'; - print('Patching $newImplementation'); + print('Updating ${buildGradle.path}: adding $newImplementation'); final newGradleContent = gradleContent.replaceAll( implementationRegExp, ' implementation "$newImplementation"', ); - fBuildGradle.writeAsStringSync(newGradleContent); + buildGradle.writeAsStringSync(newGradleContent); +} + +/// Remove the cronet reference from ./example/android/app/build.gradle. +void updateExampleBuildGradle() { + final buildGradle = File('${_packageDirectory.path}/android/build.gradle'); + final gradleContent = buildGradle.readAsStringSync(); + + print('Updating ${buildGradle.path}: removing cronet reference'); + final newGradleContent = gradleContent.replaceAll( + implementationRegExp, + '', + ); + buildGradle.writeAsStringSync(newGradleContent); } /// Update pubspec.yaml and example/pubspec.yaml. From fbc1c7c3e846a50b5dd88332823212ff7e86f064 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 13:38:32 -0800 Subject: [PATCH 2/6] Fix --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 58ba47890c..190da1f2fc 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -96,7 +96,8 @@ void updateBuildGradle(String latestVersion) { /// Remove the cronet reference from ./example/android/app/build.gradle. void updateExampleBuildGradle() { - final buildGradle = File('${_packageDirectory.path}/android/build.gradle'); + final buildGradle = + File('${_packageDirectory.path}/example/android/app/build.gradle'); final gradleContent = buildGradle.readAsStringSync(); print('Updating ${buildGradle.path}: removing cronet reference'); From 89cca769f7ed0ed0f69210f93d3ecb61d21803a6 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 13:58:55 -0800 Subject: [PATCH 3/6] Update prepare_for_embedded.dart --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 190da1f2fc..8b374f6785 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -103,7 +103,7 @@ void updateExampleBuildGradle() { print('Updating ${buildGradle.path}: removing cronet reference'); final newGradleContent = gradleContent.replaceAll( implementationRegExp, - '', + ' // NOTE: removed in package:cronet_http_embedded', ); buildGradle.writeAsStringSync(newGradleContent); } From 026f19d1c36a1d3e8f65a6218a546bdab5da902f Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 14:33:35 -0800 Subject: [PATCH 4/6] Update prepare_for_embedded.dart --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 8b374f6785..aef0865ae8 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -42,6 +42,8 @@ final _cronetVersionUri = Uri.https( 'dl.google.com', 'android/maven2/org/chromium/net/group-index.xml', ); +// Finds the Google Play Services Cronet dependency line. For example: +// ' implementation "com.google.android.gms:play-services-cronet:18.0.1"' final implementationRegExp = RegExp( '^\\s*implementation [\'"]' '$_gmsDependencyName' From 4c1abf9a29135b21f1d641a0d67c27c760ce68a3 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 16:27:33 -0800 Subject: [PATCH 5/6] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 0976a756ff..bf38e2142d 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: macos-latest + runs-on: ubuntu-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] From 24069c852764dce896c7e94122a0a52d71e49186 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Tue, 2 Jan 2024 16:42:43 -0800 Subject: [PATCH 6/6] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index bf38e2142d..0976a756ff 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: ubuntu-latest + runs-on: macos-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded']