Skip to content

Commit

Permalink
updated regex and example settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jesswrd committed Oct 18, 2024
1 parent ab38f6d commit 5ac281b
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions script/tool/lib/src/gradle_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,27 @@ class GradleCheckCommand extends PackageLoopingCommand {
@visibleForTesting
static String exampleRootSettingsArtifactHubString = '''
// See $artifactHubDocumentationString for more info.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("\$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencies {
classpath "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.1"
}
}
apply plugin: "com.google.cloud.artifactregistry.gradle-plugin"
plugins {
id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1"
}
include ":app"
''';

/// Validates that [gradleLines] reads and uses a artifiact hub repository
Expand All @@ -224,27 +234,21 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin"
RepositoryPackage example, List<String> 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;
}

Expand Down

0 comments on commit 5ac281b

Please sign in to comment.