From 1723e03defa6cb53308ee6327ff8ad2960af062d Mon Sep 17 00:00:00 2001 From: jesswrd Date: Tue, 8 Oct 2024 10:20:24 -0700 Subject: [PATCH 01/17] applied plugins declaratively and updated AGP and Gradle version # Conflicts: # packages/path_provider/path_provider/example/android/app/gradle/wrapper/gradle-wrapper.properties # packages/path_provider/path_provider/example/android/build.gradle --- .../example/android/app/build.gradle | 14 +++---- .../example/android/build.gradle | 11 ----- .../example/android/settings.gradle | 42 +++++++++---------- 3 files changed, 26 insertions(+), 41 deletions(-) diff --git a/packages/path_provider/path_provider/example/android/app/build.gradle b/packages/path_provider/path_provider/example/android/app/build.gradle index 3e67e5d7f4c..95348294737 100644 --- a/packages/path_provider/path_provider/example/android/app/build.gradle +++ b/packages/path_provider/path_provider/example/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "org.jetbrains.kotlin.android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,9 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { namespace 'io.flutter.plugins.pathproviderexample' compileSdk flutter.compileSdkVersion diff --git a/packages/path_provider/path_provider/example/android/build.gradle b/packages/path_provider/path_provider/example/android/build.gradle index 0bed8906c09..b9db5700753 100644 --- a/packages/path_provider/path_provider/example/android/build.gradle +++ b/packages/path_provider/path_provider/example/android/build.gradle @@ -1,14 +1,3 @@ -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.5.2' - } -} - allprojects { repositories { // See https://github.com/flutter/flutter/blob/master/docs/ecosystem/Plugins-and-Packages-repository-structure.md#gradle-structure for more info. diff --git a/packages/path_provider/path_provider/example/android/settings.gradle b/packages/path_provider/path_provider/example/android/settings.gradle index e54a7e1fd6e..a62e3eeaabe 100644 --- a/packages/path_provider/path_provider/example/android/settings.gradle +++ b/packages/path_provider/path_provider/example/android/settings.gradle @@ -1,28 +1,26 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withInputStream { stream -> plugins.load(stream) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.1.0" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" } -// See https://github.com/flutter/flutter/blob/master/docs/ecosystem/Plugins-and-Packages-repository-structure.md#gradle-structure for more info. -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" - } -} -apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" +include ":app" \ No newline at end of file From dfa206d290a1687d3fb56e64d3eba8c0592dff77 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Fri, 18 Oct 2024 11:06:46 -0700 Subject: [PATCH 02/17] upgraded targetsdk, agp, and gradle version --- .../path_provider/example/android/app/build.gradle | 2 +- .../example/android/app/src/main/AndroidManifest.xml | 1 + .../example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- .../path_provider/example/android/settings.gradle | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/path_provider/path_provider/example/android/app/build.gradle b/packages/path_provider/path_provider/example/android/app/build.gradle index 95348294737..cd37f70f199 100644 --- a/packages/path_provider/path_provider/example/android/app/build.gradle +++ b/packages/path_provider/path_provider/example/android/app/build.gradle @@ -30,7 +30,7 @@ android { defaultConfig { applicationId "io.flutter.plugins.pathproviderexample" minSdkVersion flutter.minSdkVersion - targetSdkVersion 28 + targetSdkVersion 35 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml index df8cee7bc3b..d7289749639 100644 --- a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml +++ b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ Date: Fri, 18 Oct 2024 11:11:17 -0700 Subject: [PATCH 03/17] updated regex and example settings string --- script/tool/lib/src/gradle_check_command.dart | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index a4657560d3f..2411a59b87a 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -203,17 +203,30 @@ class GradleCheckCommand extends PackageLoopingCommand { @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See $artifactHubDocumentationString for more info. -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() } - } - dependencies { - classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" - } } -apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" + +plugins { + id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" +} + +include ":app" + '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository @@ -224,27 +237,21 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( r'github\.com.*flutter.*blob.*Plugins-and-Packages-repository-structure.*gradle-structure'); - final RegExp artifactRegistryDefinitionRegex = RegExp( - r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( - r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); + r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); - final bool artifactRegistryDefined = gradleLines - .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); if (!(documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } return documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied; } From 4d843aecdc2c3281fed1d0b211e06d8c7559dffb Mon Sep 17 00:00:00 2001 From: jesswrd Date: Fri, 18 Oct 2024 12:50:37 -0700 Subject: [PATCH 04/17] Revert "upgraded targetsdk, agp, and gradle version" This reverts commit f52aee533400991a8213da753f6a12e8ac0a7080. --- .../path_provider/example/android/app/build.gradle | 2 +- .../example/android/app/src/main/AndroidManifest.xml | 1 - .../example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- .../path_provider/example/android/settings.gradle | 5 ++--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/path_provider/path_provider/example/android/app/build.gradle b/packages/path_provider/path_provider/example/android/app/build.gradle index cd37f70f199..95348294737 100644 --- a/packages/path_provider/path_provider/example/android/app/build.gradle +++ b/packages/path_provider/path_provider/example/android/app/build.gradle @@ -30,7 +30,7 @@ android { defaultConfig { applicationId "io.flutter.plugins.pathproviderexample" minSdkVersion flutter.minSdkVersion - targetSdkVersion 35 + targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml index d7289749639..df8cee7bc3b 100644 --- a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml +++ b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ Date: Fri, 18 Oct 2024 12:56:58 -0700 Subject: [PATCH 05/17] Revert "updated regex and example settings string" This reverts commit d9045324b700947f65959ba1a7fe7533d0de3412. --- script/tool/lib/src/gradle_check_command.dart | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 2411a59b87a..a4657560d3f 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -203,30 +203,17 @@ class GradleCheckCommand extends PackageLoopingCommand { @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See $artifactHubDocumentationString for more info. -pluginManagement { - def flutterSdkPath = { - def properties = new Properties() - file("local.properties").withInputStream { properties.load(it) } - def flutterSdkPath = properties.getProperty("flutter.sdk") - assert flutterSdkPath != null, "flutter.sdk not set in local.properties" - return flutterSdkPath - }() - - includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") - - repositories { - google() - mavenCentral() - gradlePluginPortal() +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" } + } + dependencies { + classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" + } } - -plugins { - id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" -} - -include ":app" - +apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository @@ -237,21 +224,27 @@ include ":app" RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( r'github\.com.*flutter.*blob.*Plugins-and-Packages-repository-structure.*gradle-structure'); + final RegExp artifactRegistryDefinitionRegex = RegExp( + r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( - r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); + r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); + final bool artifactRegistryDefined = gradleLines + .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); if (!(documentationPresent && + artifactRegistryDefined && artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } return documentationPresent && + artifactRegistryDefined && artifactRegistryPluginApplied; } From ab38f6d3f5161ff0e343be3a0019030ac01625e1 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Fri, 18 Oct 2024 13:27:28 -0700 Subject: [PATCH 06/17] updated targetsdk, gradle, and agp version --- .../path_provider/example/android/app/build.gradle | 2 +- .../android/app/gradle/wrapper/gradle-wrapper.properties | 2 +- .../example/android/app/src/main/AndroidManifest.xml | 1 + .../path_provider/example/android/settings.gradle | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/path_provider/path_provider/example/android/app/build.gradle b/packages/path_provider/path_provider/example/android/app/build.gradle index 95348294737..cd37f70f199 100644 --- a/packages/path_provider/path_provider/example/android/app/build.gradle +++ b/packages/path_provider/path_provider/example/android/app/build.gradle @@ -30,7 +30,7 @@ android { defaultConfig { applicationId "io.flutter.plugins.pathproviderexample" minSdkVersion flutter.minSdkVersion - targetSdkVersion 28 + targetSdkVersion 35 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/packages/path_provider/path_provider/example/android/app/gradle/wrapper/gradle-wrapper.properties b/packages/path_provider/path_provider/example/android/app/gradle/wrapper/gradle-wrapper.properties index d951fac2bf3..28f5fcf9575 100644 --- a/packages/path_provider/path_provider/example/android/app/gradle/wrapper/gradle-wrapper.properties +++ b/packages/path_provider/path_provider/example/android/app/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml index df8cee7bc3b..d7289749639 100644 --- a/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml +++ b/packages/path_provider/path_provider/example/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ Date: Fri, 18 Oct 2024 13:27:55 -0700 Subject: [PATCH 07/17] updated regex and example settings --- script/tool/lib/src/gradle_check_command.dart | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index a4657560d3f..d59d44bfc64 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -203,17 +203,27 @@ class GradleCheckCommand extends PackageLoopingCommand { @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See $artifactHubDocumentationString for more info. -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() } - } - dependencies { - classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" - } } -apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" +plugins { + id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" +} +include ":app" '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository @@ -224,27 +234,21 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( r'github\.com.*flutter.*blob.*Plugins-and-Packages-repository-structure.*gradle-structure'); - final RegExp artifactRegistryDefinitionRegex = RegExp( - r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( - r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); + r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); - final bool artifactRegistryDefined = gradleLines - .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); if (!(documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } return documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied; } From 00c057989df3a584ca5172fcb22f7467f3ca4ea2 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 21 Oct 2024 13:57:59 -0700 Subject: [PATCH 08/17] added regex for declarative way --- script/tool/lib/src/gradle_check_command.dart | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index d59d44bfc64..004e724dd5b 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -203,7 +203,24 @@ class GradleCheckCommand extends PackageLoopingCommand { @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See $artifactHubDocumentationString for more info. -pluginManagement { +buildscript { + repositories { + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" + } +} +apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" +'''; + + // GP stands for the gradle plugin method of flutter tooling inclusion. + @visibleForTesting + static String exampleRootSettingsArtifactHubStringGP = ''' + // See $artifactHubDocumentationString for more info. + pluginManagement { def flutterSdkPath = { def properties = new Properties() file("local.properties").withInputStream { properties.load(it) } @@ -211,9 +228,9 @@ pluginManagement { assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath }() - + includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") - + repositories { google() mavenCentral() @@ -221,10 +238,12 @@ pluginManagement { } } plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + // ...other plugins id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" } include ":app" -'''; + '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository /// when ARTIFACT_HUB_REPOSITORY is set. @@ -234,22 +253,32 @@ include ":app" RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( r'github\.com.*flutter.*blob.*Plugins-and-Packages-repository-structure.*gradle-structure'); + final RegExp artifactRegistryDefinitionRegex = RegExp( + r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( + r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); + final RegExp artifactRegistryPluginApplyRegexGP = RegExp( r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); + final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); + final bool artifactRegistryDefined = gradleLines + .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); + final bool artifactRegistryPluginAppliedGP = gradleLines + .any((String line) => artifactRegistryPluginApplyRegexGP.hasMatch(line)); + + final bool validArtifactConfiguration = documentationPresent && + ((artifactRegistryDefined && artifactRegistryPluginApplied) || artifactRegistryPluginAppliedGP); - if (!(documentationPresent && - artifactRegistryPluginApplied)) { + if (!validArtifactConfiguration) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } - return documentationPresent && - artifactRegistryPluginApplied; + return validArtifactConfiguration; } /// Validates the top-level build.gradle for an example app (e.g., From 30c2c33b337ec1ad7b6770b368eff18a3bf8fb49 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 21 Oct 2024 21:06:51 -0700 Subject: [PATCH 09/17] updated changelog and added comments --- packages/path_provider/path_provider/CHANGELOG.md | 1 + script/tool/lib/src/gradle_check_command.dart | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/path_provider/path_provider/CHANGELOG.md b/packages/path_provider/path_provider/CHANGELOG.md index 78b39cf0f36..0169a8d8648 100644 --- a/packages/path_provider/path_provider/CHANGELOG.md +++ b/packages/path_provider/path_provider/CHANGELOG.md @@ -1,5 +1,6 @@ ## NEXT +* Updates example app Android compileSdkVersion to 35. * Updates minimum supported SDK version to Flutter 3.19/Dart 3.3. ## 2.1.4 diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 004e724dd5b..3b43de3788c 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -216,9 +216,11 @@ buildscript { apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" '''; - // GP stands for the gradle plugin method of flutter tooling inclusion. + /// String printed as a valid example of settings.gradle repository + /// configuration that enables artifact hub env variable. + /// GP stands for the gradle plugin method of flutter tooling inclusion. @visibleForTesting - static String exampleRootSettingsArtifactHubStringGP = ''' + static String exampleSettingsArtifactHubStringGP = ''' // See $artifactHubDocumentationString for more info. pluginManagement { def flutterSdkPath = { From c87ae3078c8fbb2c1873d1e875e77c790fa49430 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Wed, 23 Oct 2024 11:22:11 -0700 Subject: [PATCH 10/17] added regex and tests --- script/tool/lib/src/gradle_check_command.dart | 39 ++++---- .../tool/test/gradle_check_command_test.dart | 96 +++++++++++++++++++ 2 files changed, 114 insertions(+), 21 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 3b43de3788c..7fa77a96a30 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -221,30 +221,24 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" /// GP stands for the gradle plugin method of flutter tooling inclusion. @visibleForTesting static String exampleSettingsArtifactHubStringGP = ''' - // See $artifactHubDocumentationString for more info. - pluginManagement { - def flutterSdkPath = { - def properties = new Properties() - file("local.properties").withInputStream { properties.load(it) } - def flutterSdkPath = properties.getProperty("flutter.sdk") - assert flutterSdkPath != null, "flutter.sdk not set in local.properties" - return flutterSdkPath - }() - - includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") - - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} +// See $artifactHubDocumentationString for more info. plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" // ...other plugins id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" } -include ":app" + '''; + + /// String printed as a valid example of settings.gradle repository + /// configuration without the artifact hub env variable. + /// GP stands for the gradle plugin method of flutter tooling inclusion. + @visibleForTesting + static String exampleSettingsWithoutArtifactHubStringGP = ''' +// See $artifactHubDocumentationString for more info. +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + // ...other plugins +} '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository @@ -275,11 +269,14 @@ include ":app" final bool validArtifactConfiguration = documentationPresent && ((artifactRegistryDefined && artifactRegistryPluginApplied) || artifactRegistryPluginAppliedGP); - if (!validArtifactConfiguration) { + if (!validArtifactConfiguration && !artifactRegistryPluginAppliedGP) { + printError('Failed Artifact Hub validation. Include the following in ' + 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); + } + if (!validArtifactConfiguration && !(artifactRegistryDefined && artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } - return validArtifactConfiguration; } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 11376e063dc..33e92f2995b 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -200,6 +200,40 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : '''); } + /// Writes a fake android/build.gradle file for an example [package] with the + /// given options. + void writeFakeExampleSettingsGradle( + RepositoryPackage package, { + bool includeArtifactHub = true, + }) { + final File settingsGradle = package + .platformDirectory(FlutterPlatform.android) + .childFile('settings.gradle'); + settingsGradle.createSync(recursive: true); + + settingsGradle.writeAsStringSync(''' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +${includeArtifactHub ? GradleCheckCommand.exampleSettingsArtifactHubStringGP : GradleCheckCommand.exampleSettingsWithoutArtifactHubStringGP} +include ":app" +'''); + } + /// Writes a fake android/app/build.gradle file for an example [package] with /// the given options. void writeFakeExampleAppBuildGradle( @@ -274,6 +308,31 @@ dependencies { ); } + void writeFakeExampleBuildGradleGP( + RepositoryPackage package, { + required String pluginName, + bool includeNamespace = true, + bool commentNamespace = false, + bool warningsConfigured = true, + String? kotlinVersion, + bool includeBuildArtifactHub = true, + bool includeSettingsArtifactHub = true, + }) { + writeFakeExampleTopLevelBuildGradle( + package, + pluginName: pluginName, + warningsConfigured: warningsConfigured, + kotlinVersion: kotlinVersion, + includeArtifactHub: includeBuildArtifactHub, + ); + writeFakeExampleAppBuildGradle(package, + includeNamespace: includeNamespace, commentNamespace: commentNamespace); + writeFakeExampleSettingsGradle( + package, + includeArtifactHub: includeSettingsArtifactHub, + ); + } + void writeFakeManifest( RepositoryPackage package, { bool isApp = false, @@ -788,6 +847,43 @@ dependencies { output, isNot(contains(GradleCheckCommand.exampleRootGradleArtifactHubString)), ); + expect( + output, + isNot(contains(GradleCheckCommand.exampleSettingsArtifactHubStringGP)), + ); + }); + + test('contains declarative method of applying gradle plugins', () async { + const String packageName = 'a_package'; + final RepositoryPackage package = + createFakePackage('a_package', packagesDir); + writeFakePluginBuildGradle(package, includeLanguageVersion: true); + writeFakeManifest(package); + final RepositoryPackage example = package.getExamples().first; + writeFakeExampleBuildGradleGP(example, + pluginName: packageName, + // ignore: avoid_redundant_argument_values + includeBuildArtifactHub: true, + includeSettingsArtifactHub: false); + writeFakeManifest(example, isApp: true); + + Error? commandError; + final List output = await runCapturingPrint( + runner, ['gradle-check'], errorHandler: (Error e) { + commandError = e; + }); + + expect(commandError, isA()); + expect( + output, + containsAllInOrder([ + contains(GradleCheckCommand.exampleSettingsArtifactHubStringGP), + ]), + ); + expect( + output, + isNot(contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), + ); }); }); From 8df5a415a8b194d188103c8cce38445046ab8911 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Thu, 24 Oct 2024 10:08:44 -0700 Subject: [PATCH 11/17] added declarative statement to the changelog --- packages/path_provider/path_provider/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/path_provider/path_provider/CHANGELOG.md b/packages/path_provider/path_provider/CHANGELOG.md index 0169a8d8648..2f57b8c1ff2 100644 --- a/packages/path_provider/path_provider/CHANGELOG.md +++ b/packages/path_provider/path_provider/CHANGELOG.md @@ -1,6 +1,6 @@ ## NEXT -* Updates example app Android compileSdkVersion to 35. +* Updates example app Android compileSdkVersion to 35 and to include flutter as a declarative dependency. * Updates minimum supported SDK version to Flutter 3.19/Dart 3.3. ## 2.1.4 From 8fc4466e77cad3e8bed9a8493650fe7e545bb179 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Thu, 24 Oct 2024 11:31:41 -0700 Subject: [PATCH 12/17] remove changelog --- packages/path_provider/path_provider/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/path_provider/path_provider/CHANGELOG.md b/packages/path_provider/path_provider/CHANGELOG.md index 2f57b8c1ff2..78b39cf0f36 100644 --- a/packages/path_provider/path_provider/CHANGELOG.md +++ b/packages/path_provider/path_provider/CHANGELOG.md @@ -1,6 +1,5 @@ ## NEXT -* Updates example app Android compileSdkVersion to 35 and to include flutter as a declarative dependency. * Updates minimum supported SDK version to Flutter 3.19/Dart 3.3. ## 2.1.4 From a73ad6074ac01799688980b16f18df8bef4323de Mon Sep 17 00:00:00 2001 From: jesswrd Date: Mon, 28 Oct 2024 11:20:17 -0700 Subject: [PATCH 13/17] moved string w/o artifact hub --- script/tool/lib/src/gradle_check_command.dart | 12 ------------ script/tool/test/gradle_check_command_test.dart | 13 ++++++++++++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 7fa77a96a30..b38e497ed1c 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -229,18 +229,6 @@ plugins { } '''; - /// String printed as a valid example of settings.gradle repository - /// configuration without the artifact hub env variable. - /// GP stands for the gradle plugin method of flutter tooling inclusion. - @visibleForTesting - static String exampleSettingsWithoutArtifactHubStringGP = ''' -// See $artifactHubDocumentationString for more info. -plugins { - id "dev.flutter.flutter-plugin-loader" version "1.0.0" - // ...other plugins -} - '''; - /// Validates that [gradleLines] reads and uses a artifiact hub repository /// when ARTIFACT_HUB_REPOSITORY is set. /// diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 33e92f2995b..4108fec0abb 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -211,6 +211,17 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : .childFile('settings.gradle'); settingsGradle.createSync(recursive: true); + /// String printed as a valid example of settings.gradle repository + /// configuration without the artifact hub env variable. + /// GP stands for the gradle plugin method of flutter tooling inclusion. + const String exampleSettingsWithoutArtifactHubStringGP = ''' +// See ${GradleCheckCommand.artifactHubDocumentationString} for more info. +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + // ...other plugins +} + '''; + settingsGradle.writeAsStringSync(''' pluginManagement { def flutterSdkPath = { @@ -229,7 +240,7 @@ pluginManagement { gradlePluginPortal() } } -${includeArtifactHub ? GradleCheckCommand.exampleSettingsArtifactHubStringGP : GradleCheckCommand.exampleSettingsWithoutArtifactHubStringGP} +${includeArtifactHub ? GradleCheckCommand.exampleSettingsArtifactHubStringGP : exampleSettingsWithoutArtifactHubStringGP} include ":app" '''); } From 80f0902721fedaa0b2e7ec7a994812519b44ac8d Mon Sep 17 00:00:00 2001 From: jesswrd Date: Tue, 29 Oct 2024 13:05:18 -0700 Subject: [PATCH 14/17] updated error logic to be more readable and added docArtifact test --- script/tool/lib/src/gradle_check_command.dart | 32 +++++++++---- .../tool/test/gradle_check_command_test.dart | 47 ++++++++++++++++--- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index b38e497ed1c..8bd2972e06c 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -221,7 +221,6 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" /// GP stands for the gradle plugin method of flutter tooling inclusion. @visibleForTesting static String exampleSettingsArtifactHubStringGP = ''' -// See $artifactHubDocumentationString for more info. plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" // ...other plugins @@ -243,6 +242,8 @@ plugins { r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); final RegExp artifactRegistryPluginApplyRegexGP = RegExp( r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); + final RegExp artifactRegistryPluginApplyDeclarativeRegex = RegExp( + r'\bpluginManagement\b'); final bool documentationPresent = gradleLines @@ -251,19 +252,30 @@ plugins { .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); - final bool artifactRegistryPluginAppliedGP = gradleLines + final bool declarativeArtifactRegistryApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegexGP.hasMatch(line)); + final bool declarativePluginBlockApplied = gradleLines + .any((String line) => artifactRegistryPluginApplyDeclarativeRegex.hasMatch(line)); + + final bool imperativeArtifactRegistryApplied = artifactRegistryDefined && artifactRegistryPluginApplied; final bool validArtifactConfiguration = documentationPresent && - ((artifactRegistryDefined && artifactRegistryPluginApplied) || artifactRegistryPluginAppliedGP); + (imperativeArtifactRegistryApplied || declarativeArtifactRegistryApplied); - if (!validArtifactConfiguration && !artifactRegistryPluginAppliedGP) { - printError('Failed Artifact Hub validation. Include the following in ' - 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); - } - if (!validArtifactConfiguration && !(artifactRegistryDefined && artifactRegistryPluginApplied)) { - printError('Failed Artifact Hub validation. Include the following in ' - 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); + if (!validArtifactConfiguration) { + printError('Failed Artifact Hub validation.'); + if (!documentationPresent) { + printError('The link to the Artifact Hub documentation is missing. Include the following in ' + 'example root settings.gradle:\n// See $artifactHubDocumentationString for more info.'); + } + if (artifactRegistryDefined || artifactRegistryPluginApplied || !declarativePluginBlockApplied) { + printError('Include the following in ' + 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); + } + else if (!declarativeArtifactRegistryApplied){ + printError('Include the following in ' + 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); + } } return validArtifactConfiguration; } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 4108fec0abb..7b5feda9519 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -205,6 +205,7 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : void writeFakeExampleSettingsGradle( RepositoryPackage package, { bool includeArtifactHub = true, + bool includeArtifactDocumentation = true, }) { final File settingsGradle = package .platformDirectory(FlutterPlatform.android) @@ -215,7 +216,6 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : /// configuration without the artifact hub env variable. /// GP stands for the gradle plugin method of flutter tooling inclusion. const String exampleSettingsWithoutArtifactHubStringGP = ''' -// See ${GradleCheckCommand.artifactHubDocumentationString} for more info. plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" // ...other plugins @@ -240,6 +240,8 @@ pluginManagement { gradlePluginPortal() } } + +${includeArtifactDocumentation ? '// See ${GradleCheckCommand.artifactHubDocumentationString} for more info.' : ''} ${includeArtifactHub ? GradleCheckCommand.exampleSettingsArtifactHubStringGP : exampleSettingsWithoutArtifactHubStringGP} include ":app" '''); @@ -328,6 +330,7 @@ dependencies { String? kotlinVersion, bool includeBuildArtifactHub = true, bool includeSettingsArtifactHub = true, + bool includeDocumentationArtifactHub = true, }) { writeFakeExampleTopLevelBuildGradle( package, @@ -341,6 +344,7 @@ dependencies { writeFakeExampleSettingsGradle( package, includeArtifactHub: includeSettingsArtifactHub, + includeArtifactDocumentation: includeDocumentationArtifactHub, ); } @@ -858,13 +862,9 @@ dependencies { output, isNot(contains(GradleCheckCommand.exampleRootGradleArtifactHubString)), ); - expect( - output, - isNot(contains(GradleCheckCommand.exampleSettingsArtifactHubStringGP)), - ); }); - test('contains declarative method of applying gradle plugins', () async { + test('prints error for declarative method of applying gradle plugins', () async { const String packageName = 'a_package'; final RepositoryPackage package = createFakePackage('a_package', packagesDir); @@ -875,7 +875,9 @@ dependencies { pluginName: packageName, // ignore: avoid_redundant_argument_values includeBuildArtifactHub: true, - includeSettingsArtifactHub: false); + includeSettingsArtifactHub: false, + // ignore: avoid_redundant_argument_values + includeDocumentationArtifactHub: true); writeFakeManifest(example, isApp: true); Error? commandError; @@ -896,6 +898,37 @@ dependencies { isNot(contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), ); }); + + test('error message is printed when documentation link is missing', () async { + const String packageName = 'a_package'; + final RepositoryPackage package = + createFakePackage('a_package', packagesDir); + writeFakePluginBuildGradle(package, includeLanguageVersion: true); + writeFakeManifest(package); + final RepositoryPackage example = package.getExamples().first; + writeFakeExampleBuildGradleGP(example, + pluginName: packageName, + // ignore: avoid_redundant_argument_values + includeBuildArtifactHub: true, + // ignore: avoid_redundant_argument_values + includeSettingsArtifactHub: true, + includeDocumentationArtifactHub: false); + writeFakeManifest(example, isApp: true); + + Error? commandError; + final List output = await runCapturingPrint( + runner, ['gradle-check'], errorHandler: (Error e) { + commandError = e; + }); + + expect(commandError, isA()); + expect( + output, + containsAllInOrder([ + contains(GradleCheckCommand.artifactHubDocumentationString), + ]), + ); + }); }); group('Kotlin version check', () { From 5629ea36d67279161c7794854b53dd3320a9fd12 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Tue, 29 Oct 2024 16:04:32 -0700 Subject: [PATCH 15/17] separated documentation hub error check for imperative method check --- script/tool/lib/src/gradle_check_command.dart | 1 - script/tool/test/gradle_check_command_test.dart | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 8bd2972e06c..854fe3f764d 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -202,7 +202,6 @@ class GradleCheckCommand extends PackageLoopingCommand { /// configuration that enables artifact hub env variable. @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' -// See $artifactHubDocumentationString for more info. buildscript { repositories { maven { diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 7b5feda9519..089fa7e5025 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -174,6 +174,7 @@ ${warningsConfigured ? warningConfig : ''} void writeFakeExampleTopLevelSettingsGradle( RepositoryPackage package, { bool includeArtifactHub = true, + bool includeArtifactDocumentation = true, }) { final File settingsGradle = package .platformDirectory(FlutterPlatform.android) @@ -196,6 +197,7 @@ plugins.each { name, path -> include ":\$name" project(":\$name").projectDir = pluginDirectory } +${includeArtifactDocumentation ? '// See ${GradleCheckCommand.artifactHubDocumentationString} for more info.' : ''} ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : ''} '''); } @@ -305,6 +307,7 @@ dependencies { String? kotlinVersion, bool includeBuildArtifactHub = true, bool includeSettingsArtifactHub = true, + bool includeSettingsDocumentationArtifactHub = true, }) { writeFakeExampleTopLevelBuildGradle( package, @@ -318,6 +321,7 @@ dependencies { writeFakeExampleTopLevelSettingsGradle( package, includeArtifactHub: includeSettingsArtifactHub, + includeArtifactDocumentation: includeSettingsDocumentationArtifactHub, ); } @@ -330,7 +334,7 @@ dependencies { String? kotlinVersion, bool includeBuildArtifactHub = true, bool includeSettingsArtifactHub = true, - bool includeDocumentationArtifactHub = true, + bool includeSettingsDocumentationArtifactHub = true, }) { writeFakeExampleTopLevelBuildGradle( package, @@ -344,7 +348,7 @@ dependencies { writeFakeExampleSettingsGradle( package, includeArtifactHub: includeSettingsArtifactHub, - includeArtifactDocumentation: includeDocumentationArtifactHub, + includeArtifactDocumentation: includeSettingsDocumentationArtifactHub, ); } @@ -751,6 +755,8 @@ dependencies { includeBuildArtifactHub: true, // ignore: avoid_redundant_argument_values includeSettingsArtifactHub: true, + // ignore: avoid_redundant_argument_values + includeSettingsDocumentationArtifactHub: true ); writeFakeManifest(example, isApp: true); @@ -877,7 +883,7 @@ dependencies { includeBuildArtifactHub: true, includeSettingsArtifactHub: false, // ignore: avoid_redundant_argument_values - includeDocumentationArtifactHub: true); + includeSettingsDocumentationArtifactHub: true); writeFakeManifest(example, isApp: true); Error? commandError; @@ -912,7 +918,7 @@ dependencies { includeBuildArtifactHub: true, // ignore: avoid_redundant_argument_values includeSettingsArtifactHub: true, - includeDocumentationArtifactHub: false); + includeSettingsDocumentationArtifactHub: false); writeFakeManifest(example, isApp: true); Error? commandError; From d51a036dd7b1f7db623dceb0fd0ece43d0e16b40 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Wed, 30 Oct 2024 10:04:26 -0700 Subject: [PATCH 16/17] ran dart format --- script/tool/lib/src/gradle_check_command.dart | 29 +++++---- .../tool/test/gradle_check_command_test.dart | 59 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 854fe3f764d..ab6545054c3 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -241,9 +241,8 @@ plugins { r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); final RegExp artifactRegistryPluginApplyRegexGP = RegExp( r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); - final RegExp artifactRegistryPluginApplyDeclarativeRegex = RegExp( - r'\bpluginManagement\b'); - + final RegExp artifactRegistryPluginApplyDeclarativeRegex = + RegExp(r'\bpluginManagement\b'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); @@ -251,27 +250,31 @@ plugins { .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); - final bool declarativeArtifactRegistryApplied = gradleLines - .any((String line) => artifactRegistryPluginApplyRegexGP.hasMatch(line)); - final bool declarativePluginBlockApplied = gradleLines - .any((String line) => artifactRegistryPluginApplyDeclarativeRegex.hasMatch(line)); + final bool declarativeArtifactRegistryApplied = gradleLines.any( + (String line) => artifactRegistryPluginApplyRegexGP.hasMatch(line)); + final bool declarativePluginBlockApplied = gradleLines.any((String line) => + artifactRegistryPluginApplyDeclarativeRegex.hasMatch(line)); - final bool imperativeArtifactRegistryApplied = artifactRegistryDefined && artifactRegistryPluginApplied; + final bool imperativeArtifactRegistryApplied = + artifactRegistryDefined && artifactRegistryPluginApplied; final bool validArtifactConfiguration = documentationPresent && - (imperativeArtifactRegistryApplied || declarativeArtifactRegistryApplied); + (imperativeArtifactRegistryApplied || + declarativeArtifactRegistryApplied); if (!validArtifactConfiguration) { printError('Failed Artifact Hub validation.'); if (!documentationPresent) { - printError('The link to the Artifact Hub documentation is missing. Include the following in ' + printError( + 'The link to the Artifact Hub documentation is missing. Include the following in ' 'example root settings.gradle:\n// See $artifactHubDocumentationString for more info.'); } - if (artifactRegistryDefined || artifactRegistryPluginApplied || !declarativePluginBlockApplied) { + if (artifactRegistryDefined || + artifactRegistryPluginApplied || + !declarativePluginBlockApplied) { printError('Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); - } - else if (!declarativeArtifactRegistryApplied){ + } else if (!declarativeArtifactRegistryApplied) { printError('Include the following in ' 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 089fa7e5025..0a8afcc60e3 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -205,10 +205,10 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : /// Writes a fake android/build.gradle file for an example [package] with the /// given options. void writeFakeExampleSettingsGradle( - RepositoryPackage package, { - bool includeArtifactHub = true, - bool includeArtifactDocumentation = true, - }) { + RepositoryPackage package, { + bool includeArtifactHub = true, + bool includeArtifactDocumentation = true, + }) { final File settingsGradle = package .platformDirectory(FlutterPlatform.android) .childFile('settings.gradle'); @@ -326,16 +326,16 @@ dependencies { } void writeFakeExampleBuildGradleGP( - RepositoryPackage package, { - required String pluginName, - bool includeNamespace = true, - bool commentNamespace = false, - bool warningsConfigured = true, - String? kotlinVersion, - bool includeBuildArtifactHub = true, - bool includeSettingsArtifactHub = true, - bool includeSettingsDocumentationArtifactHub = true, - }) { + RepositoryPackage package, { + required String pluginName, + bool includeNamespace = true, + bool commentNamespace = false, + bool warningsConfigured = true, + String? kotlinVersion, + bool includeBuildArtifactHub = true, + bool includeSettingsArtifactHub = true, + bool includeSettingsDocumentationArtifactHub = true, + }) { writeFakeExampleTopLevelBuildGradle( package, pluginName: pluginName, @@ -748,16 +748,14 @@ dependencies { writeFakePluginBuildGradle(package, includeLanguageVersion: true); writeFakeManifest(package); final RepositoryPackage example = package.getExamples().first; - writeFakeExampleBuildGradles( - example, - pluginName: packageName, - // ignore: avoid_redundant_argument_values - includeBuildArtifactHub: true, - // ignore: avoid_redundant_argument_values - includeSettingsArtifactHub: true, - // ignore: avoid_redundant_argument_values - includeSettingsDocumentationArtifactHub: true - ); + writeFakeExampleBuildGradles(example, + pluginName: packageName, + // ignore: avoid_redundant_argument_values + includeBuildArtifactHub: true, + // ignore: avoid_redundant_argument_values + includeSettingsArtifactHub: true, + // ignore: avoid_redundant_argument_values + includeSettingsDocumentationArtifactHub: true); writeFakeManifest(example, isApp: true); final List output = @@ -870,10 +868,11 @@ dependencies { ); }); - test('prints error for declarative method of applying gradle plugins', () async { + test('prints error for declarative method of applying gradle plugins', + () async { const String packageName = 'a_package'; final RepositoryPackage package = - createFakePackage('a_package', packagesDir); + createFakePackage('a_package', packagesDir); writeFakePluginBuildGradle(package, includeLanguageVersion: true); writeFakeManifest(package); final RepositoryPackage example = package.getExamples().first; @@ -901,14 +900,16 @@ dependencies { ); expect( output, - isNot(contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), + isNot( + contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), ); }); - test('error message is printed when documentation link is missing', () async { + test('error message is printed when documentation link is missing', + () async { const String packageName = 'a_package'; final RepositoryPackage package = - createFakePackage('a_package', packagesDir); + createFakePackage('a_package', packagesDir); writeFakePluginBuildGradle(package, includeLanguageVersion: true); writeFakeManifest(package); final RepositoryPackage example = package.getExamples().first; From 55f9c9d8ed190f28da462bf4ff009127536242e6 Mon Sep 17 00:00:00 2001 From: jesswrd Date: Wed, 30 Oct 2024 10:14:04 -0700 Subject: [PATCH 17/17] made args required and removed related annotations --- script/tool/test/gradle_check_command_test.dart | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 0a8afcc60e3..457f3f40b02 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -332,9 +332,9 @@ dependencies { bool commentNamespace = false, bool warningsConfigured = true, String? kotlinVersion, - bool includeBuildArtifactHub = true, - bool includeSettingsArtifactHub = true, - bool includeSettingsDocumentationArtifactHub = true, + required bool includeBuildArtifactHub, + required bool includeSettingsArtifactHub, + required bool includeSettingsDocumentationArtifactHub, }) { writeFakeExampleTopLevelBuildGradle( package, @@ -878,10 +878,8 @@ dependencies { final RepositoryPackage example = package.getExamples().first; writeFakeExampleBuildGradleGP(example, pluginName: packageName, - // ignore: avoid_redundant_argument_values includeBuildArtifactHub: true, includeSettingsArtifactHub: false, - // ignore: avoid_redundant_argument_values includeSettingsDocumentationArtifactHub: true); writeFakeManifest(example, isApp: true); @@ -915,9 +913,7 @@ dependencies { final RepositoryPackage example = package.getExamples().first; writeFakeExampleBuildGradleGP(example, pluginName: packageName, - // ignore: avoid_redundant_argument_values includeBuildArtifactHub: true, - // ignore: avoid_redundant_argument_values includeSettingsArtifactHub: true, includeSettingsDocumentationArtifactHub: false); writeFakeManifest(example, isApp: true);