-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Applied Gradle Plugins Declaratively for path_provider
#7822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1723e03
dfa206d
1325af9
4d843ae
9e57354
ab38f6d
5ac281b
00c0579
30c2c33
c87ae30
8df5a41
8fc4466
a73ad60
80f0902
5629ea3
d51a036
55f9c9d
bf607c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,7 +221,6 @@ apply plugin: "com.google.cloud.artifactregistry.gradle-plugin" | |
| /// GP stands for the gradle plugin method of flutter tooling inclusion. | ||
| @visibleForTesting | ||
| static String exampleSettingsArtifactHubStringGP = ''' | ||
| // See $artifactHubDocumentationString for more info. | ||
| plugins { | ||
| id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
| // ...other plugins | ||
|
|
@@ -243,6 +242,8 @@ plugins { | |
| r'apply.*plugin.*com\.google\.cloud\.artifactregistry\.gradle-plugin'); | ||
| final RegExp artifactRegistryPluginApplyRegexGP = RegExp( | ||
| r'id.*com\.google\.cloud\.artifactregistry\.gradle-plugin.*version.*\b\d+\.\d+\.\d+\b'); | ||
| final RegExp artifactRegistryPluginApplyDeclarativeRegex = RegExp( | ||
| r'\bpluginManagement\b'); | ||
|
|
||
|
|
||
| final bool documentationPresent = gradleLines | ||
|
|
@@ -251,19 +252,30 @@ plugins { | |
| .any((String line) => artifactRegistryDefinitionRegex.hasMatch(line)); | ||
| final bool artifactRegistryPluginApplied = gradleLines | ||
| .any((String line) => artifactRegistryPluginApplyRegex.hasMatch(line)); | ||
| final bool artifactRegistryPluginAppliedGP = gradleLines | ||
| final bool declarativeArtifactRegistryApplied = gradleLines | ||
| .any((String line) => artifactRegistryPluginApplyRegexGP.hasMatch(line)); | ||
| final bool declarativePluginBlockApplied = gradleLines | ||
| .any((String line) => artifactRegistryPluginApplyDeclarativeRegex.hasMatch(line)); | ||
|
|
||
| final bool imperativeArtifactRegistryApplied = artifactRegistryDefined && artifactRegistryPluginApplied; | ||
|
|
||
| final bool validArtifactConfiguration = documentationPresent && | ||
| ((artifactRegistryDefined && artifactRegistryPluginApplied) || artifactRegistryPluginAppliedGP); | ||
| (imperativeArtifactRegistryApplied || declarativeArtifactRegistryApplied); | ||
|
|
||
| if (!validArtifactConfiguration && !artifactRegistryPluginAppliedGP) { | ||
| printError('Failed Artifact Hub validation. Include the following in ' | ||
| 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); | ||
| } | ||
| if (!validArtifactConfiguration && !(artifactRegistryDefined && artifactRegistryPluginApplied)) { | ||
| printError('Failed Artifact Hub validation. Include the following in ' | ||
| 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); | ||
| if (!validArtifactConfiguration) { | ||
| printError('Failed Artifact Hub validation.'); | ||
| if (!documentationPresent) { | ||
| printError('The link to the Artifact Hub documentation is missing. Include the following in ' | ||
| 'example root settings.gradle:\n// See $artifactHubDocumentationString for more info.'); | ||
| } | ||
| if (artifactRegistryDefined || artifactRegistryPluginApplied || !declarativePluginBlockApplied) { | ||
| printError('Include the following in ' | ||
| 'example root settings.gradle:\n$exampleRootSettingsArtifactHubString'); | ||
| } | ||
| else if (!declarativeArtifactRegistryApplied){ | ||
| printError('Include the following in ' | ||
| 'example root settings.gradle:\n$exampleSettingsArtifactHubStringGP'); | ||
| } | ||
| } | ||
| return validArtifactConfiguration; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the only thing is missing is the documentation, before it would print an example of what needed to be included that included the documentation, whereas now it would fail without any actionable message.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried out only removing only the documentation, and it does include an error message. I have a check for |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,7 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : | |
| void writeFakeExampleSettingsGradle( | ||
| RepositoryPackage package, { | ||
| bool includeArtifactHub = true, | ||
| bool includeArtifactDocumentation = true, | ||
| }) { | ||
| final File settingsGradle = package | ||
| .platformDirectory(FlutterPlatform.android) | ||
|
|
@@ -215,7 +216,6 @@ ${includeArtifactHub ? GradleCheckCommand.exampleRootSettingsArtifactHubString : | |
| /// configuration without the artifact hub env variable. | ||
| /// GP stands for the gradle plugin method of flutter tooling inclusion. | ||
| const String exampleSettingsWithoutArtifactHubStringGP = ''' | ||
| // See ${GradleCheckCommand.artifactHubDocumentationString} for more info. | ||
| plugins { | ||
| id "dev.flutter.flutter-plugin-loader" version "1.0.0" | ||
| // ...other plugins | ||
|
|
@@ -240,6 +240,8 @@ pluginManagement { | |
| gradlePluginPortal() | ||
| } | ||
| } | ||
|
|
||
| ${includeArtifactDocumentation ? '// See ${GradleCheckCommand.artifactHubDocumentationString} for more info.' : ''} | ||
| ${includeArtifactHub ? GradleCheckCommand.exampleSettingsArtifactHubStringGP : exampleSettingsWithoutArtifactHubStringGP} | ||
| include ":app" | ||
| '''); | ||
|
|
@@ -328,6 +330,7 @@ dependencies { | |
| String? kotlinVersion, | ||
| bool includeBuildArtifactHub = true, | ||
| bool includeSettingsArtifactHub = true, | ||
| bool includeDocumentationArtifactHub = true, | ||
| }) { | ||
| writeFakeExampleTopLevelBuildGradle( | ||
| package, | ||
|
|
@@ -341,6 +344,7 @@ dependencies { | |
| writeFakeExampleSettingsGradle( | ||
| package, | ||
| includeArtifactHub: includeSettingsArtifactHub, | ||
| includeArtifactDocumentation: includeDocumentationArtifactHub, | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -858,13 +862,9 @@ dependencies { | |
| output, | ||
| isNot(contains(GradleCheckCommand.exampleRootGradleArtifactHubString)), | ||
| ); | ||
| expect( | ||
| output, | ||
| isNot(contains(GradleCheckCommand.exampleSettingsArtifactHubStringGP)), | ||
| ); | ||
| }); | ||
|
|
||
| test('contains declarative method of applying gradle plugins', () async { | ||
| test('prints error for declarative method of applying gradle plugins', () async { | ||
| const String packageName = 'a_package'; | ||
| final RepositoryPackage package = | ||
| createFakePackage('a_package', packagesDir); | ||
|
|
@@ -875,7 +875,9 @@ dependencies { | |
| pluginName: packageName, | ||
| // ignore: avoid_redundant_argument_values | ||
|
||
| includeBuildArtifactHub: true, | ||
| includeSettingsArtifactHub: false); | ||
| includeSettingsArtifactHub: false, | ||
| // ignore: avoid_redundant_argument_values | ||
| includeDocumentationArtifactHub: true); | ||
| writeFakeManifest(example, isApp: true); | ||
|
|
||
| Error? commandError; | ||
|
|
@@ -896,6 +898,37 @@ dependencies { | |
| isNot(contains(GradleCheckCommand.exampleRootSettingsArtifactHubString)), | ||
| ); | ||
| }); | ||
|
|
||
| test('error message is printed when documentation link is missing', () async { | ||
| const String packageName = 'a_package'; | ||
| final RepositoryPackage package = | ||
| createFakePackage('a_package', packagesDir); | ||
| writeFakePluginBuildGradle(package, includeLanguageVersion: true); | ||
| writeFakeManifest(package); | ||
| final RepositoryPackage example = package.getExamples().first; | ||
| writeFakeExampleBuildGradleGP(example, | ||
| pluginName: packageName, | ||
| // ignore: avoid_redundant_argument_values | ||
| includeBuildArtifactHub: true, | ||
| // ignore: avoid_redundant_argument_values | ||
| includeSettingsArtifactHub: true, | ||
| includeDocumentationArtifactHub: false); | ||
| writeFakeManifest(example, isApp: true); | ||
|
|
||
| Error? commandError; | ||
| final List<String> output = await runCapturingPrint( | ||
| runner, <String>['gradle-check'], errorHandler: (Error e) { | ||
| commandError = e; | ||
| }); | ||
|
|
||
| expect(commandError, isA<ToolExit>()); | ||
| expect( | ||
| output, | ||
| containsAllInOrder(<Matcher>[ | ||
| contains(GradleCheckCommand.artifactHubDocumentationString), | ||
| ]), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| group('Kotlin version check', () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file needs
dart formatrun on it. (CI currently doesn't check formatting for script/tool, which is a bug.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done