diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml
index 7bc1a4f089..37e38d5415 100644
--- a/.github/workflows/cronet.yml
+++ b/.github/workflows/cronet.yml
@@ -6,10 +6,12 @@ on:
- main
- master
paths:
+ - '.github/workflows/**'
- 'pkgs/cronet_http/**'
- 'pkgs/http_client_conformance_tests/**'
pull_request:
paths:
+ - '.github/workflows/**'
- 'pkgs/cronet_http/**'
- 'pkgs/http_client_conformance_tests/**'
schedule:
@@ -19,48 +21,45 @@ env:
PUB_ENVIRONMENT: bot.github
jobs:
- analyze:
- name: Lint and static analysis
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: pkgs/cronet_http
+ verify:
+ name: Format & Analyze & Test
+ runs-on: macos-latest
+ strategy:
+ matrix:
+ package: ['cronet_http', 'cronet_http_embedded']
steps:
- uses: actions/checkout@v4
+ - uses: actions/setup-java@v4
+ with:
+ distribution: 'zulu'
+ java-version: '17'
- uses: subosito/flutter-action@v2
with:
- # TODO: Change to 'stable' when a release version of flutter
- # pins version 1.21.1 or later of 'package:test'
- channel: 'master'
+ channel: 'stable'
+ - name: Make cronet_http_embedded copy
+ if: ${{ matrix.package == 'cronet_http_embedded' }}
+ run: |
+ cp -r pkgs/cronet_http pkgs/cronet_http_embedded
+ cd pkgs/cronet_http_embedded
+ flutter pub get && dart tool/prepare_for_embedded.dart
- id: install
name: Install dependencies
+ working-directory: 'pkgs/${{ matrix.package }}'
run: flutter pub get
- name: Check formatting
+ working-directory: 'pkgs/${{ matrix.package }}'
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
+ working-directory: 'pkgs/${{ matrix.package }}'
run: flutter analyze --fatal-infos
if: always() && steps.install.outcome == 'success'
-
- test:
- # Test package:cupertino_http use flutter integration tests.
- needs: analyze
- name: "Build and test"
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-java@v4
- with:
- distribution: 'zulu'
- java-version: '17'
- - uses: subosito/flutter-action@v2
- with:
- channel: 'stable'
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
+ if: always() && steps.install.outcome == 'success'
with:
api-level: 28
- target: playstore
+ target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }}
arch: x86_64
profile: pixel
- script: cd ./pkgs/cronet_http/example && flutter test --timeout=1200s integration_test/
+ script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/
diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle
index 3a91d8a295..164d96e104 100644
--- a/pkgs/cronet_http/android/build.gradle
+++ b/pkgs/cronet_http/android/build.gradle
@@ -2,14 +2,14 @@ group 'io.flutter.plugins.cronet_http'
version '1.0-SNAPSHOT'
buildscript {
- ext.kotlin_version = '1.6.10'
+ ext.kotlin_version = '1.7.21'
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -25,6 +25,11 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.cronet_http'
+ }
+
compileSdkVersion 31
compileOptions {
@@ -41,7 +46,7 @@ android {
}
defaultConfig {
- minSdkVersion 16
+ minSdkVersion 19
}
defaultConfig {
diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle
index 88b33564c3..02e4b7551e 100644
--- a/pkgs/cronet_http/example/android/app/build.gradle
+++ b/pkgs/cronet_http/example/android/app/build.gradle
@@ -46,7 +46,7 @@ android {
applicationId "io.flutter.cronet_http_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
- minSdkVersion flutter.minSdkVersion
+ minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
diff --git a/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml b/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml
index b17be9f3cb..6170951031 100644
--- a/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml
+++ b/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml
@@ -1,4 +1,4 @@
+ package="io.flutter.cronet_http_example">
diff --git a/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml b/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml
index e8d5f3f208..254760d3ed 100644
--- a/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml
+++ b/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="io.flutter.cronet_http_example">
+ package="io.flutter.cronet_http_example">
diff --git a/pkgs/cronet_http/example/android/build.gradle b/pkgs/cronet_http/example/android/build.gradle
index 83ae220041..954fa1cd5c 100644
--- a/pkgs/cronet_http/example/android/build.gradle
+++ b/pkgs/cronet_http/example/android/build.gradle
@@ -1,12 +1,12 @@
buildscript {
- ext.kotlin_version = '1.6.10'
+ ext.kotlin_version = '1.7.21'
repositories {
google()
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.1.2'
+ classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties
index cc5527d781..cfe88f6904 100644
--- a/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart
index e0f99d7a23..2093c670b1 100644
--- a/pkgs/cronet_http/tool/prepare_for_embedded.dart
+++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart
@@ -40,7 +40,9 @@ final _cronetVersionUri = Uri.https(
'android/maven2/org/chromium/net/group-index.xml',
);
-void main() async {
+/// Runs `prepare_for_embedded.dart publish` for publishing,
+/// or only the Android dependency will be modified.
+void main(List args) async {
if (Directory.current.path.endsWith('tool')) {
_packageDirectory = Directory.current.parent;
} else {
@@ -51,6 +53,8 @@ void main() async {
updateCronetDependency(latestVersion);
updatePubSpec();
updateReadme();
+ updateImports();
+ updateEntryPoint();
}
Future _getLatestCronetVersion() async {
@@ -69,7 +73,7 @@ Future _getLatestCronetVersion() async {
return versions.last;
}
-/// Update android/build.gradle
+/// Update android/build.gradle.
void updateCronetDependency(String latestVersion) {
final fBuildGradle = File('${_packageDirectory.path}/android/build.gradle');
final gradleContent = fBuildGradle.readAsStringSync();
@@ -88,18 +92,48 @@ void updateCronetDependency(String latestVersion) {
fBuildGradle.writeAsStringSync(newGradleContent);
}
-/// Update pubspec.yaml
+/// Update pubspec.yaml and example/pubspec.yaml.
void updatePubSpec() {
+ print('Updating pubspec.yaml');
final fPubspec = File('${_packageDirectory.path}/pubspec.yaml');
final yamlEditor = YamlEditor(fPubspec.readAsStringSync())
..update(['name'], _packageName)
..update(['description'], _packageDescription);
fPubspec.writeAsStringSync(yamlEditor.toString());
+ print('Updating example/pubspec.yaml');
+ final examplePubspec = File('${_packageDirectory.path}/example/pubspec.yaml');
+ final replaced = examplePubspec
+ .readAsStringSync()
+ .replaceAll('cronet_http:', 'cronet_http_embedded:');
+ examplePubspec.writeAsStringSync(replaced);
}
-/// Move README_EMBEDDED.md to replace README.md
+/// Move README_EMBEDDED.md to replace README.md.
void updateReadme() {
+ print('Updating README.md from README_EMBEDDED.md');
File('${_packageDirectory.path}/README.md').deleteSync();
File('${_packageDirectory.path}/README_EMBEDDED.md')
.renameSync('${_packageDirectory.path}/README.md');
}
+
+void updateImports() {
+ print('Updating imports in Dart files');
+ for (final file in _packageDirectory.listSync(recursive: true)) {
+ if (file is File && file.path.endsWith('.dart')) {
+ final updatedSource = file.readAsStringSync().replaceAll(
+ 'package:cronet_http/cronet_http.dart',
+ 'package:cronet_http_embedded/cronet_http_embedded.dart',
+ );
+ file.writeAsStringSync(updatedSource);
+ }
+ }
+}
+
+void updateEntryPoint() {
+ print('Renaming cronet_http.dart to cronet_http_embedded.dart');
+ File(
+ '${_packageDirectory.path}/lib/cronet_http.dart',
+ ).renameSync(
+ '${_packageDirectory.path}/lib/cronet_http_embedded.dart',
+ );
+}