mirror of https://github.com/apache/lucene.git
Add config file sanity check for precommit.
This commit is contained in:
parent
109444fc5b
commit
39a5323999
|
@ -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')
|
||||
|
|
|
@ -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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue