From 2ef35518685d23fe6b18737367ca72d1f742d6fd Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 11:19:48 -0400 Subject: [PATCH 01/11] Adds artifact hub check to gradle command --- script/tool/lib/src/gradle_check_command.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 7520bdf2da0..54d01a0e788 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -120,6 +120,26 @@ class GradleCheckCommand extends PackageLoopingCommand { return succeeded; } + /// Validates that [gradleLines] reads and uses a artifiact hub repository + /// when ARTIFACT_HUB_REPOSITORY is set. + /// + /// Required in root gradle file. + bool _validateArtifactHubUsage( + RepositoryPackage example, List gradleLines) { + final String keyVariable = 'artifactRepoKey'; + final RegExp keyPresentRegex = + RegExp("$keyVariable\\s+=\\s+'ARTIFACT_HUB_REPOSITORY'"); + + final RegExp keyReadRegex = RegExp('if\\s+(System.getenv().containsKey($keyVariable))'); + final RegExp keyUsedRegex = RegExp('maven\\s+{\\s+url\\s+System.getenv($keyVariable)\\s+}'); + + final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); + final bool keyRead = gradleLines.any((String line) => keyReadRegex.hasMatch(line)); + final bool keyUsed = gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); + + return keyPresent && keyRead && keyUsed; + } + /// Validates the top-level build.gradle for an example app (e.g., /// some_package/example/android/build.gradle). bool _validateExampleTopLevelBuildGradle( From 2519427b5b15616f24e74394d89647412b3fc298 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 11:47:31 -0400 Subject: [PATCH 02/11] passing tests --- script/tool/lib/src/gradle_check_command.dart | 22 ++++--- .../tool/test/gradle_check_command_test.dart | 59 +++++++++++++++---- 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 54d01a0e788..fc1678097d0 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -126,18 +126,23 @@ class GradleCheckCommand extends PackageLoopingCommand { /// Required in root gradle file. bool _validateArtifactHubUsage( RepositoryPackage example, List gradleLines) { - final String keyVariable = 'artifactRepoKey'; + const String keyVariable = 'artifactRepoKey'; final RegExp keyPresentRegex = RegExp("$keyVariable\\s+=\\s+'ARTIFACT_HUB_REPOSITORY'"); - final RegExp keyReadRegex = RegExp('if\\s+(System.getenv().containsKey($keyVariable))'); - final RegExp keyUsedRegex = RegExp('maven\\s+{\\s+url\\s+System.getenv($keyVariable)\\s+}'); + final RegExp keyReadRegex = + RegExp('if\\s+\(System.getenv\(\).containsKey\($keyVariable\)\)'); + final RegExp keyUsedRegex = + RegExp('maven\\s+{\\s+url\\s+System.getenv($keyVariable)\\s+}'); - final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); - final bool keyRead = gradleLines.any((String line) => keyReadRegex.hasMatch(line)); - final bool keyUsed = gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); + final bool keyPresent = + gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); + // final bool keyRead = + // gradleLines.any((String line) => keyReadRegex.hasMatch(line)); + // final bool keyUsed = + // gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); - return keyPresent && keyRead && keyUsed; + return keyPresent; //&& keyRead && keyUsed; } /// Validates the top-level build.gradle for an example app (e.g., @@ -158,6 +163,9 @@ class GradleCheckCommand extends PackageLoopingCommand { if (!_validateKotlinVersion(package, lines)) { succeeded = false; } + if (!_validateArtifactHubUsage(package, lines)) { + succeeded = false; + } return succeeded; } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 28603d25cd1..f6d71866995 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -124,6 +124,7 @@ dependencies { required String pluginName, required bool warningsConfigured, String? kotlinVersion, + bool includeArtifactHub = true, }) { final File buildGradle = package .platformDirectory(FlutterPlatform.android) @@ -138,11 +139,20 @@ gradle.projectsEvaluated { } } } +'''; + const String artifactHubSection = ''' + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } '''; buildGradle.writeAsStringSync(''' buildscript { ${kotlinVersion == null ? '' : "ext.kotlin_version = '$kotlinVersion'"} repositories { + ${includeArtifactHub ? artifactHubSection : ''} google() mavenCentral() } @@ -224,18 +234,20 @@ dependencies { '''); } - void writeFakeExampleBuildGradles( - RepositoryPackage package, { - required String pluginName, - bool includeNamespace = true, - bool commentNamespace = false, - bool warningsConfigured = true, - String? kotlinVersion, - }) { - writeFakeExampleTopLevelBuildGradle(package, - pluginName: pluginName, - warningsConfigured: warningsConfigured, - kotlinVersion: kotlinVersion); + void writeFakeExampleBuildGradles(RepositoryPackage package, + {required String pluginName, + bool includeNamespace = true, + bool commentNamespace = false, + bool warningsConfigured = true, + String? kotlinVersion, + bool includeArtifactHub = true}) { + writeFakeExampleTopLevelBuildGradle( + package, + pluginName: pluginName, + warningsConfigured: warningsConfigured, + kotlinVersion: kotlinVersion, + includeArtifactHub: includeArtifactHub, + ); writeFakeExampleAppBuildGradle(package, includeNamespace: includeNamespace, commentNamespace: commentNamespace); } @@ -650,6 +662,29 @@ dependencies { )); }); + group('Artifact Hub check', () { + test('passes artifact if not set', () 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; + writeFakeExampleBuildGradles(example, pluginName: packageName); + writeFakeManifest(example, isApp: true); + + final List output = + await runCapturingPrint(runner, ['gradle-check']); + + expect( + output, + containsAllInOrder([ + contains('Validating android/build.gradle'), + ]), + ); + }); + }); + group('Kotlin version check', () { test('passes if not set', () async { const String packageName = 'a_package'; From 05f76af2754e9141405c75f63c88e1d78a8c33ea Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 12:45:03 -0400 Subject: [PATCH 03/11] Verify regex against actual packages --- script/tool/lib/src/gradle_check_command.dart | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index fc1678097d0..ee591fe13b6 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -129,20 +129,34 @@ class GradleCheckCommand extends PackageLoopingCommand { const String keyVariable = 'artifactRepoKey'; final RegExp keyPresentRegex = RegExp("$keyVariable\\s+=\\s+'ARTIFACT_HUB_REPOSITORY'"); - + final RegExp documentationPresentRegex = + RegExp(r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); final RegExp keyReadRegex = - RegExp('if\\s+\(System.getenv\(\).containsKey\($keyVariable\)\)'); + RegExp('if.*System\.getenv.*containsKey.*$keyVariable'); final RegExp keyUsedRegex = - RegExp('maven\\s+{\\s+url\\s+System.getenv($keyVariable)\\s+}'); + RegExp('maven.*url.*System\.getenv.*$keyVariable.*'); final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); - // final bool keyRead = - // gradleLines.any((String line) => keyReadRegex.hasMatch(line)); - // final bool keyUsed = - // gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); - - return keyPresent; //&& keyRead && keyUsed; + final bool documentationPresent = + gradleLines.any((String line) => documentationPresentRegex.hasMatch(line)); + final bool keyRead = + gradleLines.any((String line) => keyReadRegex.hasMatch(line)); + final bool keyUsed = + gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); + if (!keyPresent) { + printError('Does not have ARTIFACT_HUB_REPOSITORY'); + } + if (!documentationPresent) { + printError('Does not have ARTIFACT_HUB_REPOSITORY documenation'); + } + if (!keyRead) { + printError('Does not read ARTIFACT_HUB_REPOSITORY'); + } + if (!keyUsed) { + printError('Does not use ARTIFACT_HUB_REPOSITORY'); + } + return keyPresent && keyRead && keyUsed; } /// Validates the top-level build.gradle for an example app (e.g., From d7dd201fa46b20e4681af95f0531e9c009677710 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 12:45:45 -0400 Subject: [PATCH 04/11] All camera packages use artifact hub --- packages/camera/camera/example/android/build.gradle | 6 ++++++ .../camera/camera/example/android/settings.gradle | 13 +++++++++++++ .../camera_android/example/android/build.gradle | 6 ++++++ .../camera_android/example/android/settings.gradle | 13 +++++++++++++ 4 files changed, 38 insertions(+) diff --git a/packages/camera/camera/example/android/build.gradle b/packages/camera/camera/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/camera/camera/example/android/build.gradle +++ b/packages/camera/camera/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/camera/camera/example/android/settings.gradle b/packages/camera/camera/example/android/settings.gradle index 115da6cb4f4..ba3bd2e672c 100644 --- a/packages/camera/camera/example/android/settings.gradle +++ b/packages/camera/camera/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" \ No newline at end of file diff --git a/packages/camera/camera_android/example/android/build.gradle b/packages/camera/camera_android/example/android/build.gradle index ffbc5edde25..86c8d6ee68e 100644 --- a/packages/camera/camera_android/example/android/build.gradle +++ b/packages/camera/camera_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/camera/camera_android/example/android/settings.gradle b/packages/camera/camera_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/camera/camera_android/example/android/settings.gradle +++ b/packages/camera/camera_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" From f01bad569390f28c44cf00fa27ef1d5f28121fca Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 13:22:33 -0400 Subject: [PATCH 05/11] All passing tests --- script/tool/lib/src/gradle_check_command.dart | 37 ++++++++++------- .../tool/test/gradle_check_command_test.dart | 41 ++++++++++++++----- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index ee591fe13b6..46a618deb12 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -120,6 +120,18 @@ class GradleCheckCommand extends PackageLoopingCommand { return succeeded; } + /// String printed as example of valid example root build.gradle repository + /// configuration that enables artifact hub env variable. + @visibleForTesting + static const String exampleRootArtifactHubString = r''' + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } +'''; + /// Validates that [gradleLines] reads and uses a artifiact hub repository /// when ARTIFACT_HUB_REPOSITORY is set. /// @@ -129,8 +141,8 @@ class GradleCheckCommand extends PackageLoopingCommand { const String keyVariable = 'artifactRepoKey'; final RegExp keyPresentRegex = RegExp("$keyVariable\\s+=\\s+'ARTIFACT_HUB_REPOSITORY'"); - final RegExp documentationPresentRegex = - RegExp(r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); + final RegExp documentationPresentRegex = RegExp( + r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); final RegExp keyReadRegex = RegExp('if.*System\.getenv.*containsKey.*$keyVariable'); final RegExp keyUsedRegex = @@ -138,25 +150,22 @@ class GradleCheckCommand extends PackageLoopingCommand { final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); - final bool documentationPresent = - gradleLines.any((String line) => documentationPresentRegex.hasMatch(line)); + final bool documentationPresent = gradleLines + .any((String line) => documentationPresentRegex.hasMatch(line)); final bool keyRead = gradleLines.any((String line) => keyReadRegex.hasMatch(line)); final bool keyUsed = gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); - if (!keyPresent) { - printError('Does not have ARTIFACT_HUB_REPOSITORY'); - } + if (!documentationPresent) { - printError('Does not have ARTIFACT_HUB_REPOSITORY documenation'); - } - if (!keyRead) { - printError('Does not read ARTIFACT_HUB_REPOSITORY'); + printError('Does not link artifact hub documentation.'); } - if (!keyUsed) { - printError('Does not use ARTIFACT_HUB_REPOSITORY'); + if (!(keyPresent && keyRead && keyUsed)) { + printError('Failed Artifact Hub validation. Include the following in ' + 'example root build.gradle:\n$exampleRootArtifactHubString'); } - return keyPresent && keyRead && keyUsed; + + return keyPresent && documentationPresent && keyRead && keyUsed; } /// Validates the top-level build.gradle for an example app (e.g., diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index f6d71866995..e4f9bef19bb 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -139,20 +139,12 @@ gradle.projectsEvaluated { } } } -'''; - const String artifactHubSection = ''' - // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. - def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' - if (System.getenv().containsKey(artifactRepoKey)) { - println "Using artifact hub" - maven { url System.getenv(artifactRepoKey) } - } '''; buildGradle.writeAsStringSync(''' buildscript { ${kotlinVersion == null ? '' : "ext.kotlin_version = '$kotlinVersion'"} repositories { - ${includeArtifactHub ? artifactHubSection : ''} + ${includeArtifactHub ? GradleCheckCommand.exampleRootArtifactHubString : ''} google() mavenCentral() } @@ -663,14 +655,15 @@ dependencies { }); group('Artifact Hub check', () { - test('passes artifact if not set', () async { + test('passes artifact hub check when set', () 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; - writeFakeExampleBuildGradles(example, pluginName: packageName); + // ignore: avoid_redundant_argument_values + writeFakeExampleBuildGradles(example, pluginName: packageName, includeArtifactHub: true); writeFakeManifest(example, isApp: true); final List output = @@ -683,6 +676,32 @@ dependencies { ]), ); }); + test('fails artifact hub check when 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; + writeFakeExampleBuildGradles(example, pluginName: packageName, includeArtifactHub: 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('Does not link artifact hub documentation.'), + contains(GradleCheckCommand.exampleRootArtifactHubString), + ]), + ); + }); }); group('Kotlin version check', () { From b916ecf2deaa465f06315207094f0018c0917036 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Thu, 3 Aug 2023 18:21:36 -0400 Subject: [PATCH 06/11] Add validation for settings.gradle but no tests --- script/tool/lib/src/gradle_check_command.dart | 80 ++++++++++++++++++- .../tool/test/gradle_check_command_test.dart | 4 +- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 46a618deb12..1b25f0e058b 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -66,6 +66,12 @@ class GradleCheckCommand extends PackageLoopingCommand { if (!_validateExampleTopLevelBuildGradle(package, topLevelGradleFile)) { succeeded = false; } + final File topLevelSettingsGradleFile = + _getSettignsGradleFile(androidDir); + if (!_validateExampleTopLevelSettingsGradle( + package, topLevelSettingsGradleFile)) { + succeeded = false; + } final File appGradleFile = _getBuildGradleFile(androidDir.childDirectory('app')); @@ -82,6 +88,10 @@ class GradleCheckCommand extends PackageLoopingCommand { // Returns the gradle file in the given directory. File _getBuildGradleFile(Directory dir) => dir.childFile('build.gradle'); + // Returns the settings gradle file in the given directory. + File _getSettignsGradleFile(Directory dir) => + dir.childFile('settings.gradle'); + // Returns the main/AndroidManifest.xml file for the given package. File _getMainAndroidManifest(RepositoryPackage package, {required bool isExample}) { @@ -123,7 +133,7 @@ class GradleCheckCommand extends PackageLoopingCommand { /// String printed as example of valid example root build.gradle repository /// configuration that enables artifact hub env variable. @visibleForTesting - static const String exampleRootArtifactHubString = r''' + static const String exampleRootGradleArtifactHubString = r''' // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' if (System.getenv().containsKey(artifactRepoKey)) { @@ -162,12 +172,78 @@ class GradleCheckCommand extends PackageLoopingCommand { } if (!(keyPresent && keyRead && keyUsed)) { printError('Failed Artifact Hub validation. Include the following in ' - 'example root build.gradle:\n$exampleRootArtifactHubString'); + 'example root build.gradle:\n$exampleRootGradleArtifactHubString'); } return keyPresent && documentationPresent && keyRead && keyUsed; } + /// Validates the top-level settings.gradle for an example app (e.g., + /// some_package/example/android/settings.gradle). + _validateExampleTopLevelSettingsGradle( + RepositoryPackage package, File gradleSettingsFile) { + print('${indentation}Validating ' + '${getRelativePosixPath(gradleSettingsFile, from: package.directory)}.'); + final String contents = gradleSettingsFile.readAsStringSync(); + final List lines = contents.split('\n'); + // This is tracked as a variable rather than a sequence of &&s so that all + // failures are reported at once, not just the first one. + bool succeeded = true; + if (!_validateArtifactHubSettingsUsage(package, lines)) { + succeeded = false; + } + return succeeded; + } + + @visibleForTesting + static String exampleRootSettingsArtifactHubString = ''' +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" +'''; + + /// Validates that [gradleLines] reads and uses a artifiact hub repository + /// when ARTIFACT_HUB_REPOSITORY is set. + /// + /// Required in root gradle file. + bool _validateArtifactHubSettingsUsage( + RepositoryPackage example, List gradleLines) { + final RegExp documentationPresentRegex = RegExp( + r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); + final RegExp artifactRegistryDefinitionRegex = RegExp( + 'classpath.*gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin'); + final RegExp artifactRegistryPluginApplyRegex = RegExp( + '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) { + printError('Does not link artifact hub documentation.'); + } + if (!(artifactRegistryDefined && artifactRegistryPluginApplied)) { + printError('Failed Artifact Hub validation. Include the following in ' + 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); + } + + return documentationPresent && + artifactRegistryDefined && + artifactRegistryPluginApplied; + } + /// Validates the top-level build.gradle for an example app (e.g., /// some_package/example/android/build.gradle). bool _validateExampleTopLevelBuildGradle( diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index e4f9bef19bb..a60955d885e 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -144,7 +144,7 @@ gradle.projectsEvaluated { buildscript { ${kotlinVersion == null ? '' : "ext.kotlin_version = '$kotlinVersion'"} repositories { - ${includeArtifactHub ? GradleCheckCommand.exampleRootArtifactHubString : ''} + ${includeArtifactHub ? GradleCheckCommand.exampleRootGradleArtifactHubString : ''} google() mavenCentral() } @@ -698,7 +698,7 @@ dependencies { output, containsAllInOrder([ contains('Does not link artifact hub documentation.'), - contains(GradleCheckCommand.exampleRootArtifactHubString), + contains(GradleCheckCommand.exampleRootGradleArtifactHubString), ]), ); }); From b7e8bead542ed82ab4df3c593db84cd46c7e11e5 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Fri, 4 Aug 2023 10:18:24 -0400 Subject: [PATCH 07/11] Add tests for settings.gradle check --- script/tool/lib/src/gradle_check_command.dart | 2 + .../tool/test/gradle_check_command_test.dart | 146 ++++++++++++++++-- 2 files changed, 135 insertions(+), 13 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 1b25f0e058b..2be4455890a 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -195,6 +195,8 @@ class GradleCheckCommand extends PackageLoopingCommand { return succeeded; } + /// String printed as example of valid example root settings.gradle repository + /// configuration that enables artifact hub env variable. @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index a60955d885e..49855ee1744 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -177,6 +177,37 @@ ${warningsConfigured ? warningConfig : ''} '''); } + /// Writes a fake android/build.gradle file for an example [package] with the + /// given options. + void writeFakeExampleTopLevelSettingsGradle( + RepositoryPackage package, { + bool includeArtifactHub = true, + }) { + final File settingsGradle = package + .platformDirectory(FlutterPlatform.android) + .childFile('settings.gradle'); + settingsGradle.createSync(recursive: true); + + settingsGradle.writeAsStringSync(''' +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":\$name" + project(":\$name").projectDir = pluginDirectory +} +${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : ''} +'''); + } + /// Writes a fake android/app/build.gradle file for an example [package] with /// the given options. void writeFakeExampleAppBuildGradle( @@ -226,22 +257,29 @@ dependencies { '''); } - void writeFakeExampleBuildGradles(RepositoryPackage package, - {required String pluginName, - bool includeNamespace = true, - bool commentNamespace = false, - bool warningsConfigured = true, - String? kotlinVersion, - bool includeArtifactHub = true}) { + void writeFakeExampleBuildGradles( + 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: includeArtifactHub, + includeArtifactHub: includeBuildArtifactHub, ); writeFakeExampleAppBuildGradle(package, includeNamespace: includeNamespace, commentNamespace: commentNamespace); + writeFakeExampleTopLevelSettingsGradle( + package, + includeArtifactHub: includeSettingsArtifactHub, + ); } void writeFakeManifest( @@ -655,15 +693,21 @@ dependencies { }); group('Artifact Hub check', () { - test('passes artifact hub check when set', () async { + test('passes build.gradle artifact hub check when set', () 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; - // ignore: avoid_redundant_argument_values - writeFakeExampleBuildGradles(example, pluginName: packageName, includeArtifactHub: true); + writeFakeExampleBuildGradles( + example, + pluginName: packageName, + // ignore: avoid_redundant_argument_values + includeBuildArtifactHub: true, + // ignore: avoid_redundant_argument_values + includeSettingsArtifactHub: true, + ); writeFakeManifest(example, isApp: true); final List output = @@ -673,19 +717,56 @@ dependencies { output, containsAllInOrder([ contains('Validating android/build.gradle'), + contains('Validating android/settings.gradle'), ]), ); }); - test('fails artifact hub check when missing', () async { + test('fails artifact hub check when build and settings sections 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; - writeFakeExampleBuildGradles(example, pluginName: packageName, includeArtifactHub: false); + writeFakeExampleBuildGradles( + example, + pluginName: packageName, + includeBuildArtifactHub: false, + 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('Does not link artifact hub documentation.'), + contains(GradleCheckCommand.exampleRootGradleArtifactHubString), + contains(GradleCheckCommand.exampleRootSettingsArtifactHubString), + ]), + ); + }); + + test('fails build.gradle artifact hub check when 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; + writeFakeExampleBuildGradles(example, + pluginName: packageName, + includeBuildArtifactHub: false, + // ignore: avoid_redundant_argument_values + includeSettingsArtifactHub: true); + writeFakeManifest(example, isApp: true); Error? commandError; final List output = await runCapturingPrint( @@ -701,6 +782,45 @@ dependencies { contains(GradleCheckCommand.exampleRootGradleArtifactHubString), ]), ); + expect( + output, + isNot( + contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), + ); + }); + + test('fails settings.gradle artifact hub check when 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; + writeFakeExampleBuildGradles(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('Does not link artifact hub documentation.'), + contains(GradleCheckCommand.exampleRootSettingsArtifactHubString), + ]), + ); + expect( + output, + isNot(contains(GradleCheckCommand.exampleRootGradleArtifactHubString)), + ); }); }); From 5d37c2aec4055ca432f1cf2172c9d267d4d833eb Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Fri, 4 Aug 2023 10:52:52 -0400 Subject: [PATCH 08/11] Update all example build.gradle and settings.gradle files --- packages/animations/example/android/build.gradle | 6 ++++++ .../animations/example/android/settings.gradle | 13 +++++++++++++ .../dynamic_layouts/example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ packages/espresso/example/android/build.gradle | 6 ++++++ packages/espresso/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../file_selector/example/android/build.gradle | 6 ++++++ .../file_selector/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../flutter_markdown/example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ packages/go_router/example/android/build.gradle | 6 ++++++ .../go_router/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../google_sign_in/example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../image_picker/example/android/build.gradle | 6 ++++++ .../image_picker/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../in_app_purchase/example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../local_auth/example/android/build.gradle | 6 ++++++ .../local_auth/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../path_provider/example/android/build.gradle | 6 ++++++ .../path_provider/example/android/settings.gradle | 15 ++++++++++++++- .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 15 ++++++++++++++- packages/pigeon/example/app/android/build.gradle | 6 ++++++ .../pigeon/example/app/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../test_plugin/example/android/build.gradle | 6 ++++++ .../test_plugin/example/android/settings.gradle | 13 +++++++++++++ .../quick_actions/example/android/build.gradle | 6 ++++++ .../quick_actions/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ packages/rfw/example/hello/android/build.gradle | 6 ++++++ .../rfw/example/hello/android/settings.gradle | 13 +++++++++++++ packages/rfw/example/local/android/build.gradle | 6 ++++++ .../rfw/example/local/android/settings.gradle | 13 +++++++++++++ packages/rfw/example/remote/android/build.gradle | 6 ++++++ .../rfw/example/remote/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../url_launcher/example/android/build.gradle | 6 ++++++ .../url_launcher/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../video_player/example/android/build.gradle | 6 ++++++ .../video_player/example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 10 ++++++++-- .../example/android/settings.gradle | 13 +++++++++++++ .../webview_flutter/example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ .../example/android/build.gradle | 6 ++++++ .../example/android/settings.gradle | 13 +++++++++++++ script/tool/lib/src/gradle_check_command.dart | 2 +- 79 files changed, 746 insertions(+), 5 deletions(-) diff --git a/packages/animations/example/android/build.gradle b/packages/animations/example/android/build.gradle index ce647a433bd..582d60a2faa 100644 --- a/packages/animations/example/android/build.gradle +++ b/packages/animations/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/animations/example/android/settings.gradle b/packages/animations/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/animations/example/android/settings.gradle +++ b/packages/animations/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/dynamic_layouts/example/android/build.gradle b/packages/dynamic_layouts/example/android/build.gradle index ce647a433bd..582d60a2faa 100644 --- a/packages/dynamic_layouts/example/android/build.gradle +++ b/packages/dynamic_layouts/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/dynamic_layouts/example/android/settings.gradle b/packages/dynamic_layouts/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/dynamic_layouts/example/android/settings.gradle +++ b/packages/dynamic_layouts/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/espresso/example/android/build.gradle b/packages/espresso/example/android/build.gradle index 8940eb77b62..d1a176866bf 100644 --- a/packages/espresso/example/android/build.gradle +++ b/packages/espresso/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/espresso/example/android/settings.gradle b/packages/espresso/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/espresso/example/android/settings.gradle +++ b/packages/espresso/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/android/build.gradle b/packages/extension_google_sign_in_as_googleapis_auth/example/android/build.gradle index 3843f2b4fe6..bc0712b2a23 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/android/build.gradle +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/android/build.gradle @@ -12,6 +12,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/android/settings.gradle b/packages/extension_google_sign_in_as_googleapis_auth/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/android/settings.gradle +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/file_selector/file_selector/example/android/build.gradle b/packages/file_selector/file_selector/example/android/build.gradle index f7eb7f63ce1..39a10a52cbe 100644 --- a/packages/file_selector/file_selector/example/android/build.gradle +++ b/packages/file_selector/file_selector/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/file_selector/file_selector/example/android/settings.gradle b/packages/file_selector/file_selector/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/file_selector/file_selector/example/android/settings.gradle +++ b/packages/file_selector/file_selector/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/file_selector/file_selector_android/example/android/build.gradle b/packages/file_selector/file_selector_android/example/android/build.gradle index d4d51942c4a..e36f0fd3705 100644 --- a/packages/file_selector/file_selector_android/example/android/build.gradle +++ b/packages/file_selector/file_selector_android/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/file_selector/file_selector_android/example/android/settings.gradle b/packages/file_selector/file_selector_android/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/file_selector/file_selector_android/example/android/settings.gradle +++ b/packages/file_selector/file_selector_android/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/flutter_adaptive_scaffold/example/android/build.gradle b/packages/flutter_adaptive_scaffold/example/android/build.gradle index ce647a433bd..582d60a2faa 100644 --- a/packages/flutter_adaptive_scaffold/example/android/build.gradle +++ b/packages/flutter_adaptive_scaffold/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/flutter_adaptive_scaffold/example/android/settings.gradle b/packages/flutter_adaptive_scaffold/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/flutter_adaptive_scaffold/example/android/settings.gradle +++ b/packages/flutter_adaptive_scaffold/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/flutter_markdown/example/android/build.gradle b/packages/flutter_markdown/example/android/build.gradle index ce647a433bd..582d60a2faa 100644 --- a/packages/flutter_markdown/example/android/build.gradle +++ b/packages/flutter_markdown/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/flutter_markdown/example/android/settings.gradle b/packages/flutter_markdown/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/flutter_markdown/example/android/settings.gradle +++ b/packages/flutter_markdown/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/flutter_plugin_android_lifecycle/example/android/build.gradle b/packages/flutter_plugin_android_lifecycle/example/android/build.gradle index 3d566d3568d..dc5a8d1453e 100644 --- a/packages/flutter_plugin_android_lifecycle/example/android/build.gradle +++ b/packages/flutter_plugin_android_lifecycle/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/flutter_plugin_android_lifecycle/example/android/settings.gradle b/packages/flutter_plugin_android_lifecycle/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/flutter_plugin_android_lifecycle/example/android/settings.gradle +++ b/packages/flutter_plugin_android_lifecycle/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/go_router/example/android/build.gradle b/packages/go_router/example/android/build.gradle index 586557f0afc..228f12cefbc 100644 --- a/packages/go_router/example/android/build.gradle +++ b/packages/go_router/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/go_router/example/android/settings.gradle b/packages/go_router/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/go_router/example/android/settings.gradle +++ b/packages/go_router/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/google_maps_flutter/google_maps_flutter/example/android/build.gradle b/packages/google_maps_flutter/google_maps_flutter/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/android/build.gradle +++ b/packages/google_maps_flutter/google_maps_flutter/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/android/settings.gradle b/packages/google_maps_flutter/google_maps_flutter/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/android/settings.gradle +++ b/packages/google_maps_flutter/google_maps_flutter/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle b/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle index 6aa87d48bb2..82953dd04ae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/android/settings.gradle b/packages/google_maps_flutter/google_maps_flutter_android/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/android/settings.gradle +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/google_sign_in/google_sign_in/example/android/build.gradle b/packages/google_sign_in/google_sign_in/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/google_sign_in/google_sign_in/example/android/build.gradle +++ b/packages/google_sign_in/google_sign_in/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/google_sign_in/google_sign_in/example/android/settings.gradle b/packages/google_sign_in/google_sign_in/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/google_sign_in/google_sign_in/example/android/settings.gradle +++ b/packages/google_sign_in/google_sign_in/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/google_sign_in/google_sign_in_android/example/android/build.gradle b/packages/google_sign_in/google_sign_in_android/example/android/build.gradle index 0a4256a8d02..6091524e1f1 100644 --- a/packages/google_sign_in/google_sign_in_android/example/android/build.gradle +++ b/packages/google_sign_in/google_sign_in_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/google_sign_in/google_sign_in_android/example/android/settings.gradle b/packages/google_sign_in/google_sign_in_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/google_sign_in/google_sign_in_android/example/android/settings.gradle +++ b/packages/google_sign_in/google_sign_in_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/image_picker/image_picker/example/android/build.gradle b/packages/image_picker/image_picker/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100755 --- a/packages/image_picker/image_picker/example/android/build.gradle +++ b/packages/image_picker/image_picker/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/image_picker/image_picker/example/android/settings.gradle b/packages/image_picker/image_picker/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100755 --- a/packages/image_picker/image_picker/example/android/settings.gradle +++ b/packages/image_picker/image_picker/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/image_picker/image_picker_android/example/android/build.gradle b/packages/image_picker/image_picker_android/example/android/build.gradle index 5222cc753d5..381a331887a 100755 --- a/packages/image_picker/image_picker_android/example/android/build.gradle +++ b/packages/image_picker/image_picker_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/image_picker/image_picker_android/example/android/settings.gradle b/packages/image_picker/image_picker_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100755 --- a/packages/image_picker/image_picker_android/example/android/settings.gradle +++ b/packages/image_picker/image_picker_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/in_app_purchase/in_app_purchase/example/android/build.gradle b/packages/in_app_purchase/in_app_purchase/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/in_app_purchase/in_app_purchase/example/android/build.gradle +++ b/packages/in_app_purchase/in_app_purchase/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/in_app_purchase/in_app_purchase/example/android/settings.gradle b/packages/in_app_purchase/in_app_purchase/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/in_app_purchase/in_app_purchase/example/android/settings.gradle +++ b/packages/in_app_purchase/in_app_purchase/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/in_app_purchase/in_app_purchase_android/example/android/build.gradle b/packages/in_app_purchase/in_app_purchase_android/example/android/build.gradle index 358c72fca7b..6f7af720610 100644 --- a/packages/in_app_purchase/in_app_purchase_android/example/android/build.gradle +++ b/packages/in_app_purchase/in_app_purchase_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/in_app_purchase/in_app_purchase_android/example/android/settings.gradle b/packages/in_app_purchase/in_app_purchase_android/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/in_app_purchase/in_app_purchase_android/example/android/settings.gradle +++ b/packages/in_app_purchase/in_app_purchase_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/local_auth/local_auth/example/android/build.gradle b/packages/local_auth/local_auth/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/local_auth/local_auth/example/android/build.gradle +++ b/packages/local_auth/local_auth/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/local_auth/local_auth/example/android/settings.gradle b/packages/local_auth/local_auth/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/local_auth/local_auth/example/android/settings.gradle +++ b/packages/local_auth/local_auth/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/local_auth/local_auth_android/example/android/build.gradle b/packages/local_auth/local_auth_android/example/android/build.gradle index ab40396e822..da0dec5c327 100644 --- a/packages/local_auth/local_auth_android/example/android/build.gradle +++ b/packages/local_auth/local_auth_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/local_auth/local_auth_android/example/android/settings.gradle b/packages/local_auth/local_auth_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/local_auth/local_auth_android/example/android/settings.gradle +++ b/packages/local_auth/local_auth_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/palette_generator/example/android/build.gradle b/packages/palette_generator/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/palette_generator/example/android/build.gradle +++ b/packages/palette_generator/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/palette_generator/example/android/settings.gradle b/packages/palette_generator/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/palette_generator/example/android/settings.gradle +++ b/packages/palette_generator/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/path_provider/path_provider/example/android/build.gradle b/packages/path_provider/path_provider/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/path_provider/path_provider/example/android/build.gradle +++ b/packages/path_provider/path_provider/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/path_provider/path_provider/example/android/settings.gradle b/packages/path_provider/path_provider/example/android/settings.gradle index 6cb349eef1b..0360c9f26f6 100644 --- a/packages/path_provider/path_provider/example/android/settings.gradle +++ b/packages/path_provider/path_provider/example/android/settings.gradle @@ -12,4 +12,17 @@ plugins.each { name, path -> def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() include ":$name" project(":$name").projectDir = pluginDirectory -} \ No newline at end of file +} + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/path_provider/path_provider_android/example/android/build.gradle b/packages/path_provider/path_provider_android/example/android/build.gradle index 34a17f4de0e..d3f76d61183 100644 --- a/packages/path_provider/path_provider_android/example/android/build.gradle +++ b/packages/path_provider/path_provider_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/path_provider/path_provider_android/example/android/settings.gradle b/packages/path_provider/path_provider_android/example/android/settings.gradle index 6cb349eef1b..0360c9f26f6 100644 --- a/packages/path_provider/path_provider_android/example/android/settings.gradle +++ b/packages/path_provider/path_provider_android/example/android/settings.gradle @@ -12,4 +12,17 @@ plugins.each { name, path -> def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() include ":$name" project(":$name").projectDir = pluginDirectory -} \ No newline at end of file +} + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/pigeon/example/app/android/build.gradle b/packages/pigeon/example/app/android/build.gradle index f7eb7f63ce1..39a10a52cbe 100644 --- a/packages/pigeon/example/app/android/build.gradle +++ b/packages/pigeon/example/app/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/pigeon/example/app/android/settings.gradle b/packages/pigeon/example/app/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/pigeon/example/app/android/settings.gradle +++ b/packages/pigeon/example/app/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/build.gradle b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/build.gradle index 51e204962c0..3c7f9bd24a2 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/build.gradle +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/settings.gradle b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/settings.gradle +++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/pigeon/platform_tests/test_plugin/example/android/build.gradle b/packages/pigeon/platform_tests/test_plugin/example/android/build.gradle index 13270f694c5..26e1ce2d030 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/android/build.gradle +++ b/packages/pigeon/platform_tests/test_plugin/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/pigeon/platform_tests/test_plugin/example/android/settings.gradle b/packages/pigeon/platform_tests/test_plugin/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/pigeon/platform_tests/test_plugin/example/android/settings.gradle +++ b/packages/pigeon/platform_tests/test_plugin/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/quick_actions/quick_actions/example/android/build.gradle b/packages/quick_actions/quick_actions/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/quick_actions/quick_actions/example/android/build.gradle +++ b/packages/quick_actions/quick_actions/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/quick_actions/quick_actions/example/android/settings.gradle b/packages/quick_actions/quick_actions/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/quick_actions/quick_actions/example/android/settings.gradle +++ b/packages/quick_actions/quick_actions/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/quick_actions/quick_actions_android/example/android/build.gradle b/packages/quick_actions/quick_actions_android/example/android/build.gradle index edc0f1923c1..309906a212f 100644 --- a/packages/quick_actions/quick_actions_android/example/android/build.gradle +++ b/packages/quick_actions/quick_actions_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/quick_actions/quick_actions_android/example/android/settings.gradle b/packages/quick_actions/quick_actions_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/quick_actions/quick_actions_android/example/android/settings.gradle +++ b/packages/quick_actions/quick_actions_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/rfw/example/hello/android/build.gradle b/packages/rfw/example/hello/android/build.gradle index 586557f0afc..228f12cefbc 100644 --- a/packages/rfw/example/hello/android/build.gradle +++ b/packages/rfw/example/hello/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/rfw/example/hello/android/settings.gradle b/packages/rfw/example/hello/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/rfw/example/hello/android/settings.gradle +++ b/packages/rfw/example/hello/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/rfw/example/local/android/build.gradle b/packages/rfw/example/local/android/build.gradle index 586557f0afc..228f12cefbc 100644 --- a/packages/rfw/example/local/android/build.gradle +++ b/packages/rfw/example/local/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/rfw/example/local/android/settings.gradle b/packages/rfw/example/local/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/rfw/example/local/android/settings.gradle +++ b/packages/rfw/example/local/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/rfw/example/remote/android/build.gradle b/packages/rfw/example/remote/android/build.gradle index 586557f0afc..228f12cefbc 100644 --- a/packages/rfw/example/remote/android/build.gradle +++ b/packages/rfw/example/remote/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/rfw/example/remote/android/settings.gradle b/packages/rfw/example/remote/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/rfw/example/remote/android/settings.gradle +++ b/packages/rfw/example/remote/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/shared_preferences/shared_preferences/example/android/build.gradle b/packages/shared_preferences/shared_preferences/example/android/build.gradle index ce647a433bd..582d60a2faa 100644 --- a/packages/shared_preferences/shared_preferences/example/android/build.gradle +++ b/packages/shared_preferences/shared_preferences/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/shared_preferences/shared_preferences/example/android/settings.gradle b/packages/shared_preferences/shared_preferences/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/shared_preferences/shared_preferences/example/android/settings.gradle +++ b/packages/shared_preferences/shared_preferences/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/shared_preferences/shared_preferences_android/example/android/build.gradle b/packages/shared_preferences/shared_preferences_android/example/android/build.gradle index f6f6475fb39..3cd5d4a83c4 100644 --- a/packages/shared_preferences/shared_preferences_android/example/android/build.gradle +++ b/packages/shared_preferences/shared_preferences_android/example/android/build.gradle @@ -13,6 +13,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/shared_preferences/shared_preferences_android/example/android/settings.gradle b/packages/shared_preferences/shared_preferences_android/example/android/settings.gradle index 44e62bcf06a..3a97314b38c 100644 --- a/packages/shared_preferences/shared_preferences_android/example/android/settings.gradle +++ b/packages/shared_preferences/shared_preferences_android/example/android/settings.gradle @@ -9,3 +9,16 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/url_launcher/url_launcher/example/android/build.gradle b/packages/url_launcher/url_launcher/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/url_launcher/url_launcher/example/android/build.gradle +++ b/packages/url_launcher/url_launcher/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/url_launcher/url_launcher/example/android/settings.gradle b/packages/url_launcher/url_launcher/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/url_launcher/url_launcher/example/android/settings.gradle +++ b/packages/url_launcher/url_launcher/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/url_launcher/url_launcher_android/example/android/build.gradle b/packages/url_launcher/url_launcher_android/example/android/build.gradle index 8a0165753a9..40cbdf3c0de 100644 --- a/packages/url_launcher/url_launcher_android/example/android/build.gradle +++ b/packages/url_launcher/url_launcher_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/url_launcher/url_launcher_android/example/android/settings.gradle b/packages/url_launcher/url_launcher_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/url_launcher/url_launcher_android/example/android/settings.gradle +++ b/packages/url_launcher/url_launcher_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/video_player/video_player/example/android/build.gradle b/packages/video_player/video_player/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/video_player/video_player/example/android/build.gradle +++ b/packages/video_player/video_player/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/video_player/video_player/example/android/settings.gradle b/packages/video_player/video_player/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/video_player/video_player/example/android/settings.gradle +++ b/packages/video_player/video_player/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/video_player/video_player_android/example/android/build.gradle b/packages/video_player/video_player_android/example/android/build.gradle index bc26b58842c..0a2199e8925 100644 --- a/packages/video_player/video_player_android/example/android/build.gradle +++ b/packages/video_player/video_player_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } @@ -39,9 +45,9 @@ gradle.projectsEvaluated { // Workaround for several warnings when building // that the above turns into errors, coming from - // org.checkerframework.checker.nullness.qual and + // org.checkerframework.checker.nullness.qual and // com.google.errorprone.annotations: - // + // // warning: Cannot find annotation method 'value()' in type // 'EnsuresNonNull': class file for // org.checkerframework.checker.nullness.qual.EnsuresNonNull not found diff --git a/packages/video_player/video_player_android/example/android/settings.gradle b/packages/video_player/video_player_android/example/android/settings.gradle index 115da6cb4f4..0360c9f26f6 100644 --- a/packages/video_player/video_player_android/example/android/settings.gradle +++ b/packages/video_player/video_player_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/webview_flutter/webview_flutter/example/android/build.gradle b/packages/webview_flutter/webview_flutter/example/android/build.gradle index 0822484928b..6ae7ddc2ce5 100644 --- a/packages/webview_flutter/webview_flutter/example/android/build.gradle +++ b/packages/webview_flutter/webview_flutter/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/webview_flutter/webview_flutter/example/android/settings.gradle b/packages/webview_flutter/webview_flutter/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/webview_flutter/webview_flutter/example/android/settings.gradle +++ b/packages/webview_flutter/webview_flutter/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/packages/webview_flutter/webview_flutter_android/example/android/build.gradle b/packages/webview_flutter/webview_flutter_android/example/android/build.gradle index 566572be2e5..f87c8c63983 100644 --- a/packages/webview_flutter/webview_flutter_android/example/android/build.gradle +++ b/packages/webview_flutter/webview_flutter_android/example/android/build.gradle @@ -11,6 +11,12 @@ buildscript { allprojects { repositories { + // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' + if (System.getenv().containsKey(artifactRepoKey)) { + println "Using artifact hub" + maven { url System.getenv(artifactRepoKey) } + } google() mavenCentral() } diff --git a/packages/webview_flutter/webview_flutter_android/example/android/settings.gradle b/packages/webview_flutter/webview_flutter_android/example/android/settings.gradle index 5a2f14fb18f..8d7543314fa 100644 --- a/packages/webview_flutter/webview_flutter_android/example/android/settings.gradle +++ b/packages/webview_flutter/webview_flutter_android/example/android/settings.gradle @@ -13,3 +13,16 @@ plugins.each { name, path -> include ":$name" project(":$name").projectDir = pluginDirectory } + +// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#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" diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 2be4455890a..ff87db9efcb 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -180,7 +180,7 @@ class GradleCheckCommand extends PackageLoopingCommand { /// Validates the top-level settings.gradle for an example app (e.g., /// some_package/example/android/settings.gradle). - _validateExampleTopLevelSettingsGradle( + bool _validateExampleTopLevelSettingsGradle( RepositoryPackage package, File gradleSettingsFile) { print('${indentation}Validating ' '${getRelativePosixPath(gradleSettingsFile, from: package.directory)}.'); From d78c475c7e711dec06730a8eea16bf04d36795fb Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Fri, 4 Aug 2023 11:22:15 -0400 Subject: [PATCH 09/11] make analyzer happy --- script/tool/lib/src/gradle_check_command.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index ff87db9efcb..b69551715a2 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -154,9 +154,9 @@ class GradleCheckCommand extends PackageLoopingCommand { final RegExp documentationPresentRegex = RegExp( r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); final RegExp keyReadRegex = - RegExp('if.*System\.getenv.*containsKey.*$keyVariable'); + RegExp('if.*System.getenv.*containsKey.*$keyVariable'); final RegExp keyUsedRegex = - RegExp('maven.*url.*System\.getenv.*$keyVariable.*'); + RegExp('maven.*url.*System.getenv.*$keyVariable.*'); final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); From d82c7446bbafcf77bc8a23a64001649cf1c6da59 Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Fri, 4 Aug 2023 14:35:52 -0400 Subject: [PATCH 10/11] pr feedback --- script/tool/lib/src/gradle_check_command.dart | 23 ++++++++++--------- .../tool/test/gradle_check_command_test.dart | 2 -- 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 b69551715a2..20ac2bbd326 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -130,11 +130,16 @@ class GradleCheckCommand extends PackageLoopingCommand { return succeeded; } + /// Documentation url for Artifact hub implementation in flutter repo's. + @visibleForTesting + static const String artifactHubDocumentationString = + r'https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure'; + /// String printed as example of valid example root build.gradle repository /// configuration that enables artifact hub env variable. @visibleForTesting - static const String exampleRootGradleArtifactHubString = r''' - // See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. + static const String exampleRootGradleArtifactHubString = ''' + // See $artifactHubDocumentationString for more info. def artifactRepoKey = 'ARTIFACT_HUB_REPOSITORY' if (System.getenv().containsKey(artifactRepoKey)) { println "Using artifact hub" @@ -167,10 +172,7 @@ class GradleCheckCommand extends PackageLoopingCommand { final bool keyUsed = gradleLines.any((String line) => keyUsedRegex.hasMatch(line)); - if (!documentationPresent) { - printError('Does not link artifact hub documentation.'); - } - if (!(keyPresent && keyRead && keyUsed)) { + if (!(documentationPresent && keyPresent && keyRead && keyUsed)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root build.gradle:\n$exampleRootGradleArtifactHubString'); } @@ -199,7 +201,7 @@ class GradleCheckCommand extends PackageLoopingCommand { /// configuration that enables artifact hub env variable. @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' -// See https://github.com/flutter/flutter/wiki/Plugins-and-Packages-repository-structure#gradle-structure for more info. +// See $artifactHubDocumentationString for more info. buildscript { repositories { maven { @@ -233,10 +235,9 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); - if (!documentationPresent) { - printError('Does not link artifact hub documentation.'); - } - if (!(artifactRegistryDefined && artifactRegistryPluginApplied)) { + if (!(documentationPresent && + artifactRegistryDefined && + artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 49855ee1744..9e0a0a2d2aa 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -747,7 +747,6 @@ dependencies { expect( output, containsAllInOrder([ - contains('Does not link artifact hub documentation.'), contains(GradleCheckCommand.exampleRootGradleArtifactHubString), contains(GradleCheckCommand.exampleRootSettingsArtifactHubString), ]), @@ -813,7 +812,6 @@ dependencies { expect( output, containsAllInOrder([ - contains('Does not link artifact hub documentation.'), contains(GradleCheckCommand.exampleRootSettingsArtifactHubString), ]), ); From a7dee37f437856235d59fe6494da4cd3ee06297c Mon Sep 17 00:00:00 2001 From: Reid Baker Date: Mon, 7 Aug 2023 10:22:15 -0400 Subject: [PATCH 11/11] code review feedback --- script/tool/lib/src/gradle_check_command.dart | 19 ++++++++++--------- .../tool/test/gradle_check_command_test.dart | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 20ac2bbd326..e1af42fd724 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -67,7 +67,7 @@ class GradleCheckCommand extends PackageLoopingCommand { succeeded = false; } final File topLevelSettingsGradleFile = - _getSettignsGradleFile(androidDir); + _getSettingsGradleFile(androidDir); if (!_validateExampleTopLevelSettingsGradle( package, topLevelSettingsGradleFile)) { succeeded = false; @@ -89,7 +89,7 @@ class GradleCheckCommand extends PackageLoopingCommand { File _getBuildGradleFile(Directory dir) => dir.childFile('build.gradle'); // Returns the settings gradle file in the given directory. - File _getSettignsGradleFile(Directory dir) => + File _getSettingsGradleFile(Directory dir) => dir.childFile('settings.gradle'); // Returns the main/AndroidManifest.xml file for the given package. @@ -153,15 +153,16 @@ class GradleCheckCommand extends PackageLoopingCommand { /// Required in root gradle file. bool _validateArtifactHubUsage( RepositoryPackage example, List gradleLines) { + // Gradle variable name used to hold environment variable string. const String keyVariable = 'artifactRepoKey'; final RegExp keyPresentRegex = - RegExp("$keyVariable\\s+=\\s+'ARTIFACT_HUB_REPOSITORY'"); + RegExp('$keyVariable' r"\s+=\s+'ARTIFACT_HUB_REPOSITORY'"); final RegExp documentationPresentRegex = RegExp( - r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); + r'github\.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); final RegExp keyReadRegex = - RegExp('if.*System.getenv.*containsKey.*$keyVariable'); + RegExp(r'if.*System\.getenv.*\.containsKey.*' '$keyVariable'); final RegExp keyUsedRegex = - RegExp('maven.*url.*System.getenv.*$keyVariable.*'); + RegExp(r'maven.*url.*System\.getenv\(' '$keyVariable'); final bool keyPresent = gradleLines.any((String line) => keyPresentRegex.hasMatch(line)); @@ -222,11 +223,11 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" bool _validateArtifactHubSettingsUsage( RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( - r'github.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); + r'github\.com.*wiki.*Plugins-and-Packages-repository-structure.*gradle-structure'); final RegExp artifactRegistryDefinitionRegex = RegExp( - 'classpath.*gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin'); + r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( - 'apply.*plugin.*com.google.cloud.artifactregistry.gradle-plugin'); + r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index 9e0a0a2d2aa..a7db8317b94 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -777,7 +777,6 @@ dependencies { expect( output, containsAllInOrder([ - contains('Does not link artifact hub documentation.'), contains(GradleCheckCommand.exampleRootGradleArtifactHubString), ]), );