You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2020/01/10 11:54:19 UTC
[lucene-solr] 01/03: Add config file sanity check for precommit.
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch gradle-master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 39a5323999ffaa0bf3dbd46b00521aaf46a289bc
Author: Dawid Weiss <dw...@apache.org>
AuthorDate: Fri Jan 10 12:49:04 2020 +0100
Add config file sanity check for precommit.
---
build.gradle | 1 +
gradle/validation/config-file-sanity.gradle | 42 +++++++++++++++++++++++++++++
gradle/validation/precommit.gradle | 12 ++++++---
3 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/build.gradle b/build.gradle
index f18d89a..3a3f6e5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -40,6 +40,7 @@ apply from: file('gradle/validation/jar-checks.gradle')
apply from: file('gradle/validation/git-status.gradle')
apply from: file('gradle/validation/versions-props-sorted.gradle')
apply from: file('gradle/validation/validate-source-patterns.gradle')
+apply from: file('gradle/validation/config-file-sanity.gradle')
// Additional development aids.
apply from: file('gradle/maven/maven-local.gradle')
diff --git a/gradle/validation/config-file-sanity.gradle b/gradle/validation/config-file-sanity.gradle
new file mode 100644
index 0000000..b4885e2
--- /dev/null
+++ b/gradle/validation/config-file-sanity.gradle
@@ -0,0 +1,42 @@
+// An equivalent of ant's "check-example-lucene-match-version"
+
+configure(project(":solr")) {
+ task validateConfigFileSanity() {
+ doFirst {
+ def matchVersion = project(":solr:core").testOptionsResolved['tests.luceneMatchVersion']
+ if (!matchVersion) {
+ throw new GradleException("tests.luceneMatchVersion not defined?")
+ }
+
+ // Verify solrconfig.xml files declare proper luceneMatchVersion.
+ [
+ file("server/solr/configsets"),
+ file("example")
+ ].each { configsetsDir ->
+ def configFiles = fileTree(configsetsDir, {
+ include "**/solrconfig.xml"
+ })
+
+ configFiles.each { file ->
+ def content = file.getText("UTF-8")
+ if (!content.contains("<luceneMatchVersion>${matchVersion}<")) {
+ throw new GradleException("Configset does not refer to the correct luceneMatchVersion (${matchVersion}): ${file.absolutePath}")
+ }
+ }
+ }
+
+ def configsetsDir = file("server/solr/configsets")
+ def subdirs = configsetsDir.listFiles({file -> file.isDirectory() } as FileFilter)
+
+ if (subdirs.size() == 0) {
+ throw new GradleException("No sub-directories found under ${configsetsDir}?")
+ }
+
+ subdirs.each { dir ->
+ if (fileTree(dir, { include "**/solrconfig.xml" }).asList().isEmpty()) {
+ throw new GradleException("No solrconfig.xml file under: ${dir}")
+ }
+ }
+ }
+ }
+}
diff --git a/gradle/validation/precommit.gradle b/gradle/validation/precommit.gradle
index 717f870..403f259 100644
--- a/gradle/validation/precommit.gradle
+++ b/gradle/validation/precommit.gradle
@@ -5,14 +5,17 @@ configure(rootProject) {
group = 'Precommit'
description = "All precommit checks"
- // Root-level dependencies.
- dependsOn verifyLocks
+ // Root-level validation tasks.
+ dependsOn ":verifyLocks"
dependsOn ":versionsPropsAreSorted"
dependsOn ":checkWorkingCopyPristine"
dependsOn ":validateSourcePatterns"
- // Attach tasks from other projects using lazy collection
- // as they may not yet be defined.
+ // Solr validation tasks.
+ dependsOn ":solr:validateConfigFileSanity"
+
+ // Attach all these tasks from all projects that have them.
+ // This uses lazy collections as they may not yet be defined.
dependsOn allprojects.collect { prj ->
prj.tasks.matching { task -> task.name in [
"forbiddenApisMain",
@@ -22,3 +25,4 @@ configure(rootProject) {
}
}
}
+