From b29a5a87617f5cdc2cdd4c9da58f45781f8e6694 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 10:59:03 -0800 Subject: [PATCH 1/8] first two tests good state --- .../test/update_dependency_command_test.dart | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index 6488c673fe4..6ac4a76eb38 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -907,6 +907,63 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip 'gradle-$newGradleVersion-all.zip')); }); }); + group('agp', () { + final List invalidAGPVersionsFormat = [ + '81', + '811.1', + '8.123', + '8.12.12' + ]; + + for (final String AGPVersion in invalidAGPVersionsFormat) { + test('throws because AGPVersion: $AGPVersion is invalid', () async { + Error? commandError; + final List output = await runCapturingPrint(runner, [ + 'update-dependency', + '--android-dependency', + 'androidGradlePlugin', + '--version', + AGPVersion, + ], errorHandler: (Error e) { + commandError = e; + }); + + expect(commandError, isA()); + expect( + output, + containsAllInOrder([ + contains(''' +A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) must be provided. + 1. The first number must have one or two digits + 2. The second number must have one or two digits + 3. If present, the third number must have a single digit'''), + ]), + ); + }); + } + + test('skips if example app does not run on Android', () async { + final RepositoryPackage package = + createFakePlugin('fake_plugin', packagesDir); + + final List output = await runCapturingPrint(runner, [ + 'update-dependency', + '--packages', + package.displayName, + '--android-dependency', + 'androidGradlePlugin', + '--version', + '8.11.1', + ]); + + expect( + output, + containsAllInOrder([ + contains('SKIPPING: No example apps run on Android.'), + ]), + ); + }); + }); group('compileSdk/compileSdkForExamples', () { // Tests if the compileSdk version is updated for the provided From b3fae2e3590a50cf49991ba1aa109b2ca8c33249 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 11:58:42 -0800 Subject: [PATCH 2/8] everything in good state --- .../lib/src/update_dependency_command.dart | 32 ++++++- .../test/update_dependency_command_test.dart | 93 +++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index 02c118e0d20..bd880cecd1e 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -44,12 +44,15 @@ class UpdateDependencyCommand extends PackageLoopingCommand { help: 'An Android dependency to update.', allowed: [ _AndroidDepdencyType.gradle, + _AndroidDepdencyType.androidGradlePlugin, _AndroidDepdencyType.compileSdk, _AndroidDepdencyType.compileSdkForExamples, ], allowedHelp: { _AndroidDepdencyType.gradle: 'Updates Gradle version used in plugin example apps.', + _AndroidDepdencyType.androidGradlePlugin: + 'Updates AGP version used in plugin example apps.', _AndroidDepdencyType.compileSdk: 'Updates compileSdk version used to compile plugins.', _AndroidDepdencyType.compileSdkForExamples: @@ -150,7 +153,22 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus 3. If present, the third number must have a single digit'''); throw ToolExit(_exitInvalidTargetVersion); } - } else if (_targetAndroidDependency == _AndroidDepdencyType.compileSdk || + } else if (_targetAndroidDependency == + _AndroidDepdencyType.androidGradlePlugin) { + final RegExp validAGPVersionPattern = + RegExp(r'^\d{1,2}\.\d{1,2}(?:\.\d)?$'); + final bool isValidAGPVersion = + validAGPVersionPattern.stringMatch(version) == version; + if (!isValidAGPVersion) { + printError(''' +A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) must be provided. + 1. The first number must have one or two digits + 2. The second number must have one or two digits + 3. If present, the third number must have a single digit'''); + throw ToolExit(_exitInvalidTargetVersion); + } + } else if (_targetAndroidDependency == + _AndroidDepdencyType.compileSdk || _targetAndroidDependency == _AndroidDepdencyType.compileSdkForExamples) { final RegExp validSdkVersion = RegExp(r'^\d{1,2}$'); @@ -258,7 +276,9 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus return _runForCompileSdkVersion(package); } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle || _targetAndroidDependency == - _AndroidDepdencyType.compileSdkForExamples) { + _AndroidDepdencyType.compileSdkForExamples || + _targetAndroidDependency == + _AndroidDepdencyType.androidGradlePlugin) { return _runForAndroidDependencyOnExamples(package); } @@ -317,6 +337,13 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus dependencyVersionPattern = RegExp( r'(compileSdk|compileSdkVersion) (\d{1,2}|flutter.compileSdkVersion)'); newDependencyVersionEntry = 'compileSdk $_targetVersion'; + } else if (_targetAndroidDependency == + _AndroidDepdencyType.androidGradlePlugin) { + filesToUpdate.add(androidDirectory.childFile('settings.gradle')); + dependencyVersionPattern = RegExp( + r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', multiLine: true); + newDependencyVersionEntry = + 'id "com.android.application" version "$_targetVersion" apply false'; } else { printError( 'Target Android dependency $_targetAndroidDependency is unrecognized.'); @@ -506,6 +533,7 @@ enum _PubDependencyType { normal, dev } class _AndroidDepdencyType { static const String gradle = 'gradle'; + static const String androidGradlePlugin = 'androidGradlePlugin'; static const String compileSdk = 'compileSdk'; static const String compileSdkForExamples = 'compileSdkForExamples'; } diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index 6ac4a76eb38..8a3850d3d8c 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -963,6 +963,99 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus ]), ); }); + + test( + 'succeeds if example app has android/settings.gradle structure', + () async { + final RepositoryPackage package = + createFakePlugin('fake_plugin', packagesDir, extraFiles: [ + 'example/android/settings.gradle' + ]); + const String newAGPVersion = '9.9'; + + final File gradleSettingsFile = package.directory + .childDirectory('example') + .childDirectory('android') + .childFile('settings.gradle'); + + gradleSettingsFile.writeAsStringSync(r''' +... +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.11.1" apply false +... +} +... +'''); + + await runCapturingPrint(runner, [ + 'update-dependency', + '--packages', + package.displayName, + '--android-dependency', + 'androidGradlePlugin', + '--version', + newAGPVersion, + ]); + + final String updatedGradleSettingsContents = + gradleSettingsFile.readAsStringSync(); + + expect( + updatedGradleSettingsContents, + contains( + r'id "com.android.application" version ' + '"$newAGPVersion" apply false')); + }); + + test( + 'succeeds if one example app runs on Android and another does not', + () async { + final RepositoryPackage package = createFakePlugin( + 'fake_plugin', packagesDir, examples: [ + 'example_1', + 'example_2' + ], extraFiles: [ + 'example/example_2/android/settings.gradle' + ]); + const String newAGPVersion = '9.9'; + + final File gradleSettingsFile = package.directory + .childDirectory('example') + .childDirectory('example_2') + .childDirectory('android') + .childFile('settings.gradle'); + + gradleSettingsFile.writeAsStringSync(r''' +... +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.11.1" apply false +... +} +... +'''); + + await runCapturingPrint(runner, [ + 'update-dependency', + '--packages', + package.displayName, + '--android-dependency', + 'androidGradlePlugin', + '--version', + newAGPVersion, + ]); + + final String updatedGradleSettingsContents = + gradleSettingsFile.readAsStringSync(); + + expect( + updatedGradleSettingsContents, + contains( + r'id "com.android.application" version ' + '"$newAGPVersion" apply false')); + }); + }); group('compileSdk/compileSdkForExamples', () { From 40a46a8d994a90aac10c20ca7f32966f772cdb52 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 12:03:51 -0800 Subject: [PATCH 3/8] agp to camel case --- .../test/update_dependency_command_test.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index 8a3850d3d8c..3cd702371df 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -908,22 +908,22 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip }); }); group('agp', () { - final List invalidAGPVersionsFormat = [ + final List invalidAgpVersionsFormat = [ '81', '811.1', '8.123', '8.12.12' ]; - for (final String AGPVersion in invalidAGPVersionsFormat) { - test('throws because AGPVersion: $AGPVersion is invalid', () async { + for (final String agpVersion in invalidAgpVersionsFormat) { + test('throws because agpVersion: $agpVersion is invalid', () async { Error? commandError; final List output = await runCapturingPrint(runner, [ 'update-dependency', '--android-dependency', 'androidGradlePlugin', '--version', - AGPVersion, + agpVersion, ], errorHandler: (Error e) { commandError = e; }); @@ -971,7 +971,7 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus createFakePlugin('fake_plugin', packagesDir, extraFiles: [ 'example/android/settings.gradle' ]); - const String newAGPVersion = '9.9'; + const String newAgpVersion = '9.9'; final File gradleSettingsFile = package.directory .childDirectory('example') @@ -995,7 +995,7 @@ plugins { '--android-dependency', 'androidGradlePlugin', '--version', - newAGPVersion, + newAgpVersion, ]); final String updatedGradleSettingsContents = @@ -1005,7 +1005,7 @@ plugins { updatedGradleSettingsContents, contains( r'id "com.android.application" version ' - '"$newAGPVersion" apply false')); + '"$newAgpVersion" apply false')); }); test( @@ -1018,7 +1018,7 @@ plugins { ], extraFiles: [ 'example/example_2/android/settings.gradle' ]); - const String newAGPVersion = '9.9'; + const String newAgpVersion = '9.9'; final File gradleSettingsFile = package.directory .childDirectory('example') @@ -1043,7 +1043,7 @@ plugins { '--android-dependency', 'androidGradlePlugin', '--version', - newAGPVersion, + newAgpVersion, ]); final String updatedGradleSettingsContents = @@ -1053,7 +1053,7 @@ plugins { updatedGradleSettingsContents, contains( r'id "com.android.application" version ' - '"$newAGPVersion" apply false')); + '"$newAgpVersion" apply false')); }); }); From 716904bac732adbb33e847bfa84a62c53041079b Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 12:04:31 -0800 Subject: [PATCH 4/8] dart format --- .../lib/src/update_dependency_command.dart | 9 +- .../test/update_dependency_command_test.dart | 125 ++++++++---------- 2 files changed, 62 insertions(+), 72 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index bd880cecd1e..370527872b7 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -167,8 +167,7 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus 3. If present, the third number must have a single digit'''); throw ToolExit(_exitInvalidTargetVersion); } - } else if (_targetAndroidDependency == - _AndroidDepdencyType.compileSdk || + } else if (_targetAndroidDependency == _AndroidDepdencyType.compileSdk || _targetAndroidDependency == _AndroidDepdencyType.compileSdkForExamples) { final RegExp validSdkVersion = RegExp(r'^\d{1,2}$'); @@ -277,8 +276,7 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle || _targetAndroidDependency == _AndroidDepdencyType.compileSdkForExamples || - _targetAndroidDependency == - _AndroidDepdencyType.androidGradlePlugin) { + _targetAndroidDependency == _AndroidDepdencyType.androidGradlePlugin) { return _runForAndroidDependencyOnExamples(package); } @@ -341,7 +339,8 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus _AndroidDepdencyType.androidGradlePlugin) { filesToUpdate.add(androidDirectory.childFile('settings.gradle')); dependencyVersionPattern = RegExp( - r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', multiLine: true); + r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', + multiLine: true); newDependencyVersionEntry = 'id "com.android.application" version "$_targetVersion" apply false'; } else { diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index 3cd702371df..e7982b298c4 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -964,21 +964,19 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus ); }); - test( - 'succeeds if example app has android/settings.gradle structure', - () async { - final RepositoryPackage package = - createFakePlugin('fake_plugin', packagesDir, extraFiles: [ - 'example/android/settings.gradle' - ]); - const String newAgpVersion = '9.9'; + test('succeeds if example app has android/settings.gradle structure', + () async { + final RepositoryPackage package = createFakePlugin( + 'fake_plugin', packagesDir, + extraFiles: ['example/android/settings.gradle']); + const String newAgpVersion = '9.9'; - final File gradleSettingsFile = package.directory - .childDirectory('example') - .childDirectory('android') - .childFile('settings.gradle'); + final File gradleSettingsFile = package.directory + .childDirectory('example') + .childDirectory('android') + .childFile('settings.gradle'); - gradleSettingsFile.writeAsStringSync(r''' + gradleSettingsFile.writeAsStringSync(r''' ... plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" @@ -988,45 +986,40 @@ plugins { ... '''); - await runCapturingPrint(runner, [ - 'update-dependency', - '--packages', - package.displayName, - '--android-dependency', - 'androidGradlePlugin', - '--version', - newAgpVersion, - ]); - - final String updatedGradleSettingsContents = + await runCapturingPrint(runner, [ + 'update-dependency', + '--packages', + package.displayName, + '--android-dependency', + 'androidGradlePlugin', + '--version', + newAgpVersion, + ]); + + final String updatedGradleSettingsContents = gradleSettingsFile.readAsStringSync(); - expect( - updatedGradleSettingsContents, - contains( - r'id "com.android.application" version ' - '"$newAgpVersion" apply false')); - }); + expect( + updatedGradleSettingsContents, + contains(r'id "com.android.application" version ' + '"$newAgpVersion" apply false')); + }); - test( - 'succeeds if one example app runs on Android and another does not', - () async { - final RepositoryPackage package = createFakePlugin( - 'fake_plugin', packagesDir, examples: [ - 'example_1', - 'example_2' - ], extraFiles: [ - 'example/example_2/android/settings.gradle' - ]); - const String newAgpVersion = '9.9'; - - final File gradleSettingsFile = package.directory - .childDirectory('example') - .childDirectory('example_2') - .childDirectory('android') - .childFile('settings.gradle'); - - gradleSettingsFile.writeAsStringSync(r''' + test('succeeds if one example app runs on Android and another does not', + () async { + final RepositoryPackage package = createFakePlugin( + 'fake_plugin', packagesDir, + examples: ['example_1', 'example_2'], + extraFiles: ['example/example_2/android/settings.gradle']); + const String newAgpVersion = '9.9'; + + final File gradleSettingsFile = package.directory + .childDirectory('example') + .childDirectory('example_2') + .childDirectory('android') + .childFile('settings.gradle'); + + gradleSettingsFile.writeAsStringSync(r''' ... plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" @@ -1036,26 +1029,24 @@ plugins { ... '''); - await runCapturingPrint(runner, [ - 'update-dependency', - '--packages', - package.displayName, - '--android-dependency', - 'androidGradlePlugin', - '--version', - newAgpVersion, - ]); - - final String updatedGradleSettingsContents = - gradleSettingsFile.readAsStringSync(); + await runCapturingPrint(runner, [ + 'update-dependency', + '--packages', + package.displayName, + '--android-dependency', + 'androidGradlePlugin', + '--version', + newAgpVersion, + ]); - expect( - updatedGradleSettingsContents, - contains( - r'id "com.android.application" version ' - '"$newAgpVersion" apply false')); - }); + final String updatedGradleSettingsContents = + gradleSettingsFile.readAsStringSync(); + expect( + updatedGradleSettingsContents, + contains(r'id "com.android.application" version ' + '"$newAgpVersion" apply false')); + }); }); group('compileSdk/compileSdkForExamples', () { From 9492113581bff49f801bf4b2182042ba2671bf48 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 12:12:07 -0800 Subject: [PATCH 5/8] agp and gradle have same vers req for now --- .../lib/src/update_dependency_command.dart | 26 +++++-------------- .../test/update_dependency_command_test.dart | 25 +++++++----------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index 370527872b7..c115c293dea 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -140,26 +140,14 @@ ${response.httpResponse.body} if (version == null) { printError('A version must be provided to update this dependency.'); throw ToolExit(_exitNoTargetVersion); - } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle) { - final RegExp validGradleVersionPattern = - RegExp(r'^\d{1,2}\.\d{1,2}(?:\.\d)?$'); - final bool isValidGradleVersion = - validGradleVersionPattern.stringMatch(version) == version; - if (!isValidGradleVersion) { - printError(''' -A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) must be provided. - 1. The first number must have one or two digits - 2. The second number must have one or two digits - 3. If present, the third number must have a single digit'''); - throw ToolExit(_exitInvalidTargetVersion); - } - } else if (_targetAndroidDependency == - _AndroidDepdencyType.androidGradlePlugin) { - final RegExp validAGPVersionPattern = + } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle || + _targetAndroidDependency == + _AndroidDepdencyType.androidGradlePlugin) { + final RegExp validGradleAGPVersionPattern = RegExp(r'^\d{1,2}\.\d{1,2}(?:\.\d)?$'); - final bool isValidAGPVersion = - validAGPVersionPattern.stringMatch(version) == version; - if (!isValidAGPVersion) { + final bool isValidGradleAGPVersion = + validGradleAGPVersionPattern.stringMatch(version) == version; + if (!isValidGradleAGPVersion) { printError(''' A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) must be provided. 1. The first number must have one or two digits diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index e7982b298c4..77ce5a35630 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -607,15 +607,15 @@ dev_dependencies: }); group('Android dependencies', () { - group('gradle', () { - final List invalidGradleVersionsFormat = [ - '81', - '811.1', - '8.123', - '8.12.12' - ]; + final List invalidGradleAgpVersionsFormat = [ + '81', + '811.1', + '8.123', + '8.12.12' + ]; - for (final String gradleVersion in invalidGradleVersionsFormat) { + group('gradle', () { + for (final String gradleVersion in invalidGradleAgpVersionsFormat) { test('throws because gradleVersion: $gradleVersion is invalid', () async { Error? commandError; @@ -908,14 +908,7 @@ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip }); }); group('agp', () { - final List invalidAgpVersionsFormat = [ - '81', - '811.1', - '8.123', - '8.12.12' - ]; - - for (final String agpVersion in invalidAgpVersionsFormat) { + for (final String agpVersion in invalidGradleAgpVersionsFormat) { test('throws because agpVersion: $agpVersion is invalid', () async { Error? commandError; final List output = await runCapturingPrint(runner, [ From 049e1df59aa12a1d900067885f8a21baf0c6c562 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 12:15:35 -0800 Subject: [PATCH 6/8] fix spelling --- .../lib/src/update_dependency_command.dart | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index c115c293dea..8ada86623d1 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -43,19 +43,19 @@ class UpdateDependencyCommand extends PackageLoopingCommand { argParser.addOption(_androidDependency, help: 'An Android dependency to update.', allowed: [ - _AndroidDepdencyType.gradle, - _AndroidDepdencyType.androidGradlePlugin, - _AndroidDepdencyType.compileSdk, - _AndroidDepdencyType.compileSdkForExamples, + _AndroidDependencyType.gradle, + _AndroidDependencyType.androidGradlePlugin, + _AndroidDependencyType.compileSdk, + _AndroidDependencyType.compileSdkForExamples, ], allowedHelp: { - _AndroidDepdencyType.gradle: + _AndroidDependencyType.gradle: 'Updates Gradle version used in plugin example apps.', - _AndroidDepdencyType.androidGradlePlugin: + _AndroidDependencyType.androidGradlePlugin: 'Updates AGP version used in plugin example apps.', - _AndroidDepdencyType.compileSdk: + _AndroidDependencyType.compileSdk: 'Updates compileSdk version used to compile plugins.', - _AndroidDepdencyType.compileSdkForExamples: + _AndroidDependencyType.compileSdkForExamples: 'Updates compileSdk version used to compile plugin examples.', }); argParser.addOption( @@ -140,9 +140,9 @@ ${response.httpResponse.body} if (version == null) { printError('A version must be provided to update this dependency.'); throw ToolExit(_exitNoTargetVersion); - } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle || + } else if (_targetAndroidDependency == _AndroidDependencyType.gradle || _targetAndroidDependency == - _AndroidDepdencyType.androidGradlePlugin) { + _AndroidDependencyType.androidGradlePlugin) { final RegExp validGradleAGPVersionPattern = RegExp(r'^\d{1,2}\.\d{1,2}(?:\.\d)?$'); final bool isValidGradleAGPVersion = @@ -155,9 +155,9 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus 3. If present, the third number must have a single digit'''); throw ToolExit(_exitInvalidTargetVersion); } - } else if (_targetAndroidDependency == _AndroidDepdencyType.compileSdk || + } else if (_targetAndroidDependency == _AndroidDependencyType.compileSdk || _targetAndroidDependency == - _AndroidDepdencyType.compileSdkForExamples) { + _AndroidDependencyType.compileSdkForExamples) { final RegExp validSdkVersion = RegExp(r'^\d{1,2}$'); final bool isValidSdkVersion = validSdkVersion.stringMatch(version) == version; @@ -259,12 +259,12 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus /// an Android dependency. Future _runForAndroidDependency( RepositoryPackage package) async { - if (_targetAndroidDependency == _AndroidDepdencyType.compileSdk) { + if (_targetAndroidDependency == _AndroidDependencyType.compileSdk) { return _runForCompileSdkVersion(package); - } else if (_targetAndroidDependency == _AndroidDepdencyType.gradle || + } else if (_targetAndroidDependency == _AndroidDependencyType.gradle || _targetAndroidDependency == - _AndroidDepdencyType.compileSdkForExamples || - _targetAndroidDependency == _AndroidDepdencyType.androidGradlePlugin) { + _AndroidDependencyType.compileSdkForExamples || + _targetAndroidDependency == _AndroidDependencyType.androidGradlePlugin) { return _runForAndroidDependencyOnExamples(package); } @@ -289,7 +289,7 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus final RegExp dependencyVersionPattern; final String newDependencyVersionEntry; - if (_targetAndroidDependency == _AndroidDepdencyType.gradle) { + if (_targetAndroidDependency == _AndroidDependencyType.gradle) { if (androidDirectory .childDirectory('gradle') .childDirectory('wrapper') @@ -317,14 +317,14 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus newDependencyVersionEntry = 'distributionUrl=https\\://services.gradle.org/distributions/gradle-$_targetVersion-all.zip'; } else if (_targetAndroidDependency == - _AndroidDepdencyType.compileSdkForExamples) { + _AndroidDependencyType.compileSdkForExamples) { filesToUpdate.add( androidDirectory.childDirectory('app').childFile('build.gradle')); dependencyVersionPattern = RegExp( r'(compileSdk|compileSdkVersion) (\d{1,2}|flutter.compileSdkVersion)'); newDependencyVersionEntry = 'compileSdk $_targetVersion'; } else if (_targetAndroidDependency == - _AndroidDepdencyType.androidGradlePlugin) { + _AndroidDependencyType.androidGradlePlugin) { filesToUpdate.add(androidDirectory.childFile('settings.gradle')); dependencyVersionPattern = RegExp( r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', @@ -518,7 +518,7 @@ class _PubDependencyInfo { enum _PubDependencyType { normal, dev } -class _AndroidDepdencyType { +class _AndroidDependencyType { static const String gradle = 'gradle'; static const String androidGradlePlugin = 'androidGradlePlugin'; static const String compileSdk = 'compileSdk'; From 46e610adf0c01a200f566860732ea51feccc03ca Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 10 Nov 2025 13:51:07 -0800 Subject: [PATCH 7/8] ensure file exists and format --- script/tool/lib/src/update_dependency_command.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index 8ada86623d1..cf2ee4b7664 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -155,7 +155,8 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus 3. If present, the third number must have a single digit'''); throw ToolExit(_exitInvalidTargetVersion); } - } else if (_targetAndroidDependency == _AndroidDependencyType.compileSdk || + } else if (_targetAndroidDependency == + _AndroidDependencyType.compileSdk || _targetAndroidDependency == _AndroidDependencyType.compileSdkForExamples) { final RegExp validSdkVersion = RegExp(r'^\d{1,2}$'); @@ -264,7 +265,8 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus } else if (_targetAndroidDependency == _AndroidDependencyType.gradle || _targetAndroidDependency == _AndroidDependencyType.compileSdkForExamples || - _targetAndroidDependency == _AndroidDependencyType.androidGradlePlugin) { + _targetAndroidDependency == + _AndroidDependencyType.androidGradlePlugin) { return _runForAndroidDependencyOnExamples(package); } @@ -325,7 +327,9 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus newDependencyVersionEntry = 'compileSdk $_targetVersion'; } else if (_targetAndroidDependency == _AndroidDependencyType.androidGradlePlugin) { - filesToUpdate.add(androidDirectory.childFile('settings.gradle')); + if (androidDirectory.childFile('settings.gradle').existsSync()) { + filesToUpdate.add(androidDirectory.childFile('settings.gradle')); + } dependencyVersionPattern = RegExp( r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', multiLine: true); From 62117e37b71360f8bb95cbad9f4c2aba7835d59f Mon Sep 17 00:00:00 2001 From: Jessie Wong Date: Wed, 12 Nov 2025 15:46:14 -0800 Subject: [PATCH 8/8] insert spaces --- script/tool/lib/src/update_dependency_command.dart | 2 +- script/tool/test/update_dependency_command_test.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/script/tool/lib/src/update_dependency_command.dart b/script/tool/lib/src/update_dependency_command.dart index cf2ee4b7664..75b9e7c8baf 100644 --- a/script/tool/lib/src/update_dependency_command.dart +++ b/script/tool/lib/src/update_dependency_command.dart @@ -334,7 +334,7 @@ A version with a valid format (maximum 2-3 numbers separated by 1-2 periods) mus r'^\s*id\s+"com\.android\.application"\s+version\s+"(\d{1,2}\.\d{1,2}(?:\.\d)?)"\s+apply\s+false\s*$', multiLine: true); newDependencyVersionEntry = - 'id "com.android.application" version "$_targetVersion" apply false'; + ' id "com.android.application" version "$_targetVersion" apply false'; } else { printError( 'Target Android dependency $_targetAndroidDependency is unrecognized.'); diff --git a/script/tool/test/update_dependency_command_test.dart b/script/tool/test/update_dependency_command_test.dart index 77ce5a35630..b2621435673 100644 --- a/script/tool/test/update_dependency_command_test.dart +++ b/script/tool/test/update_dependency_command_test.dart @@ -994,7 +994,7 @@ plugins { expect( updatedGradleSettingsContents, - contains(r'id "com.android.application" version ' + contains(r' id "com.android.application" version ' '"$newAgpVersion" apply false')); }); @@ -1037,7 +1037,7 @@ plugins { expect( updatedGradleSettingsContents, - contains(r'id "com.android.application" version ' + contains(r' id "com.android.application" version ' '"$newAgpVersion" apply false')); }); });