Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into more-config2
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Jan 4, 2024
2 parents 8516a9e + 473a892 commit c2cd0e8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
15 changes: 10 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Configuration for .github/workflows/pull_request_label.yml.

'type-infra':
- '.github/**'
- changed-files:
- any-glob-to-any-file: '.github/**'

'package:cronet_http':
- 'pkgs/cronet_http/**'
- changed-files:
- any-glob-to-any-file: 'pkgs/cronet_http/**'

'package:cupertino_http':
- 'pkgs/cupertino_http/**'
- changed-files:
- any-glob-to-any-file: 'pkgs/cupertino_http/**'

'package:http':
- 'pkgs/http/**'
- changed-files:
- any-glob-to-any-file: 'pkgs/http/**'

'package:http_client_conformance_tests':
- 'pkgs/http_client_conformance_tests/**'
- changed-files:
- any-glob-to-any-file: 'pkgs/http_client_conformance_tests/**'
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
41 changes: 29 additions & 12 deletions pkgs/cronet_http/tool/prepare_for_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ 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'
':\\d+.\\d+.\\d+[\'"]',
multiLine: true,
);

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

final latestVersion = await _getLatestCronetVersion();
updateCronetDependency(latestVersion);
updateBuildGradle(latestVersion);
updateExampleBuildGradle();
updatePubSpec();
updateReadme();
updateLibraryName();
Expand All @@ -75,22 +84,30 @@ Future<String> _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}/example/android/app/build.gradle');
final gradleContent = buildGradle.readAsStringSync();

print('Updating ${buildGradle.path}: removing cronet reference');
final newGradleContent = gradleContent.replaceAll(
implementationRegExp,
' // NOTE: removed in package:cronet_http_embedded',
);
buildGradle.writeAsStringSync(newGradleContent);
}

/// Update pubspec.yaml and example/pubspec.yaml.
Expand Down

0 comments on commit c2cd0e8

Please sign in to comment.