diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index a4657560d3f4..2411a59b87a1 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -203,17 +203,30 @@ class GradleCheckCommand extends PackageLoopingCommand { @visibleForTesting static String exampleRootSettingsArtifactHubString = ''' // See $artifactHubDocumentationString for more info. -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() + + includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() } - } - dependencies { - classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1" - } } -apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" + +plugins { + id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1" +} + +include ":app" + '''; /// Validates that [gradleLines] reads and uses a artifiact hub repository @@ -224,27 +237,21 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" RepositoryPackage example, List gradleLines) { final RegExp documentationPresentRegex = RegExp( r'github\.com.*flutter.*blob.*Plugins-and-Packages-repository-structure.*gradle-structure'); - final RegExp artifactRegistryDefinitionRegex = RegExp( - r'classpath.*gradle\.plugin\.com\.google\.cloud\.artifactregistry:artifactregistry-gradle-plugin'); final RegExp artifactRegistryPluginApplyRegex = RegExp( - r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); + r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); final bool documentationPresent = gradleLines .any((String line) => documentationPresentRegex.hasMatch(line)); - final bool artifactRegistryDefined = gradleLines - .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); final bool artifactRegistryPluginApplied = gradleLines .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); if (!(documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied)) { printError('Failed Artifact Hub validation. Include the following in ' 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); } return documentationPresent && - artifactRegistryDefined && artifactRegistryPluginApplied; }