[Android] Bump Gradle version to 7.6.3 (#5522)

Part of fix for https://github.com/flutter/flutter/issues/138336 by bumping the Gradle version of all package example apps (plus `image_picker_android` plugin) to 7.6.3 from those that had a version below that to fix security vulnerability.

Also fixes a bug I found while using the `update-dependencies` packages tool command that caused it to not catch all of the `gradle-wrapper.properties` files when running with the `gradle` dependency + added a test for the fix.
This commit is contained in:
Camille Simon
2023-12-13 11:21:50 -08:00
committed by GitHub
parent 12b3d59d18
commit 2b53f7253d
71 changed files with 175 additions and 92 deletions

View File

@ -780,6 +780,73 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
'gradle-$newGradleVersion-all.zip'));
});
test(
'succeeds if example app has android/gradle and android/app/gradle directory structure',
() async {
final RepositoryPackage package =
createFakePlugin('fake_plugin', packagesDir, extraFiles: <String>[
'example/android/gradle/wrapper/gradle-wrapper.properties',
'example/android/app/gradle/wrapper/gradle-wrapper.properties'
]);
const String newGradleVersion = '9.9';
final File gradleWrapperPropertiesFile = package.directory
.childDirectory('example')
.childDirectory('android')
.childDirectory('gradle')
.childDirectory('wrapper')
.childFile('gradle-wrapper.properties');
final File gradleAppWrapperPropertiesFile = package.directory
.childDirectory('example')
.childDirectory('android')
.childDirectory('app')
.childDirectory('gradle')
.childDirectory('wrapper')
.childFile('gradle-wrapper.properties');
gradleWrapperPropertiesFile.writeAsStringSync(r'''
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
''');
gradleAppWrapperPropertiesFile.writeAsStringSync(r'''
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
''');
await runCapturingPrint(runner, <String>[
'update-dependency',
'--packages',
package.displayName,
'--android-dependency',
'gradle',
'--version',
newGradleVersion,
]);
final String updatedGradleWrapperPropertiesContents =
gradleWrapperPropertiesFile.readAsStringSync();
final String updatedGradleAppWrapperPropertiesContents =
gradleAppWrapperPropertiesFile.readAsStringSync();
expect(
updatedGradleWrapperPropertiesContents,
contains(
r'distributionUrl=https\://services.gradle.org/distributions/'
'gradle-$newGradleVersion-all.zip'));
expect(
updatedGradleAppWrapperPropertiesContents,
contains(
r'distributionUrl=https\://services.gradle.org/distributions/'
'gradle-$newGradleVersion-all.zip'));
});
test('succeeds if one example app runs on Android and another does not',
() async {
final RepositoryPackage package = createFakePlugin(