You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by md...@apache.org on 2022/09/01 14:25:30 UTC
[solr] branch main updated: Allow skipping failure for RAT and Source Patterns (#992)
This is an automated email from the ASF dual-hosted git repository.
mdrob pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new eaaabbfa334 Allow skipping failure for RAT and Source Patterns (#992)
eaaabbfa334 is described below
commit eaaabbfa33456639613a7a6aecc37cd2d89e5dfa
Author: Mike Drob <md...@apache.org>
AuthorDate: Thu Sep 1 09:25:24 2022 -0500
Allow skipping failure for RAT and Source Patterns (#992)
---
gradle/globals.gradle | 13 +++++++++++++
gradle/validation/git-status.gradle | 15 ++-------------
gradle/validation/rat-sources.gradle | 6 ++----
gradle/validation/validate-source-patterns.gradle | 8 ++------
4 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/gradle/globals.gradle b/gradle/globals.gradle
index 912e6074b44..f08a033b118 100644
--- a/gradle/globals.gradle
+++ b/gradle/globals.gradle
@@ -69,6 +69,19 @@ allprojects {
return file(buildscript.sourceFile.absolutePath.replaceAll('.gradle$', ""))
}
+ failOrWarn = { propName, message, errors ->
+ if (errors) {
+ def shouldFail = Boolean.valueOf(propertyOrDefault(propName, true))
+ def msg = message + (shouldFail ? " (skip with -P${propName}=false)" : "") + ":\n${errors.join("\n")}"
+
+ if (shouldFail) {
+ throw new GradleException(msg)
+ } else {
+ logger.warn("NOTE: ${msg}")
+ }
+ }
+ }
+
// Utility function similar to project.exec but not emitting
// any output unless an error code is returned from the executed command.
quietExec = { closure ->
diff --git a/gradle/validation/git-status.gradle b/gradle/validation/git-status.gradle
index 37c3d8dce39..5ce6195bf93 100644
--- a/gradle/validation/git-status.gradle
+++ b/gradle/validation/git-status.gradle
@@ -103,19 +103,8 @@ configure(rootProject) {
files.collect {file -> " - ${file} ${fileStatus}" }
}.sort()
- if (offenders) {
- def checkProp = "validation.git.failOnModified"
- def shouldFail = Boolean.valueOf(propertyOrDefault(checkProp, true))
- def message = "Working copy is not a clean git checkout" +
- (shouldFail ? " (skip with -P${checkProp}=false)" : "") +
- ", offending files:\n${offenders.join("\n")}"
-
- if (shouldFail) {
- throw new GradleException(message)
- } else {
- logger.lifecycle("NOTE: ${message}")
- }
- }
+ def checkProp = "validation.git.failOnModified"
+ failOrWarn(checkProp, "Working copy is not a clean git checkout", offenders)
}
}
}
diff --git a/gradle/validation/rat-sources.gradle b/gradle/validation/rat-sources.gradle
index cb67fbd0792..67f563842db 100644
--- a/gradle/validation/rat-sources.gradle
+++ b/gradle/validation/rat-sources.gradle
@@ -273,10 +273,8 @@ class RatTask extends DefaultTask {
errors << "Unknown license: ${resource.@name}"
}
}
- if (errors) {
- throw new GradleException("Found " + errors.size() + " file(s) with errors:\n" +
- errors.collect{ msg -> " - ${msg}" }.join("\n"))
- }
+ def checkProp = "validation.rat.failOnError"
+ project.failOrWarn(checkProp, "Detected license header issues", errors)
}
@TaskAction
diff --git a/gradle/validation/validate-source-patterns.gradle b/gradle/validation/validate-source-patterns.gradle
index fa660d6cf79..0d22b9c0706 100644
--- a/gradle/validation/validate-source-patterns.gradle
+++ b/gradle/validation/validate-source-patterns.gradle
@@ -156,12 +156,10 @@ class ValidateSourcePatternsTask extends DefaultTask {
(~$/\n\s*var\s+.*=.*<>.*/$) : 'Diamond operators should not be used with var',
]
- def found = 0;
def violations = new TreeSet();
def reportViolation = { f, name ->
logger.error('{}: {}', name, f);
violations.add(name);
- found++;
}
def javadocsPattern = ~$/(?sm)^\Q/**\E(.*?)\Q*/\E/$;
@@ -273,9 +271,7 @@ class ValidateSourcePatternsTask extends DefaultTask {
}
progress.completed()
- if (found) {
- throw new GradleException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
- found, violations.join(', ')));
- }
+ def checkProp = "validation.sourcePatterns.failOnError"
+ project.failOrWarn(checkProp, "Found source pattern violations", violations)
}
}