mirror of https://github.com/apache/lucene.git
LUCENE-9382: update gradle to 6.4.1. (#1549)
* LUCENE-9382: update gradle to 6.4.1. Requires minor changes around log call validation by restructuring the code around switches to a series of ifs. Piggybacking: apply log validation to :solr modules. Add inputs declaration so that task is not re-run on unmodified files.
This commit is contained in:
parent
502f62cc9c
commit
3e8e5d8cf6
|
@ -22,7 +22,7 @@ import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
configure(rootProject) {
|
configure(rootProject) {
|
||||||
ext {
|
ext {
|
||||||
expectedGradleVersion = '6.0.1'
|
expectedGradleVersion = '6.4.1'
|
||||||
minJavaVersion = JavaVersion.VERSION_11
|
minJavaVersion = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,13 @@ import org.apache.tools.ant.BuildException
|
||||||
|
|
||||||
// See the associated help task "gradlew helpValidateLogCalls"
|
// See the associated help task "gradlew helpValidateLogCalls"
|
||||||
|
|
||||||
allprojects {
|
configure(subprojects.findAll { it.path.startsWith(':solr') }) {
|
||||||
plugins.withType(JavaPlugin) {
|
plugins.withType(JavaPlugin) {
|
||||||
task validateLogCalls(type: ValidateLogCallsTask) {
|
task validateLogCalls(type: ValidateLogCallsTask) {
|
||||||
description "Checks that log calls are either validated or conform to efficient patterns."
|
description "Checks that log calls are either validated or conform to efficient patterns."
|
||||||
group "verification"
|
group "verification"
|
||||||
|
|
||||||
|
sourceFiles = files(sourceSets*.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ class ValidateLogCallsTask extends DefaultTask {
|
||||||
violations.add(System.lineSeparator + msg);
|
violations.add(System.lineSeparator + msg);
|
||||||
errsFound++;
|
errsFound++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have a log.something line, check for patterns we're not fond of.
|
// We have a log.something line, check for patterns we're not fond of.
|
||||||
def checkLine(File file, String line, int lineNumber, String previous) {
|
def checkLine(File file, String line, int lineNumber, String previous) {
|
||||||
boolean violation = false
|
boolean violation = false
|
||||||
|
@ -204,31 +207,35 @@ class ValidateLogCallsTask extends DefaultTask {
|
||||||
reportViolation("Bad state, should be 0-1 in the switch statement") // make people aware the code sucks
|
reportViolation("Bad state, should be 0-1 in the switch statement") // make people aware the code sucks
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
switch (state) { // It's just easier to do this here rather than read another line in the switch above.
|
|
||||||
case 0: // Not collcting a log line
|
// It's just easier to do this here rather than read another line in the switch above.
|
||||||
|
if (state == 0) {
|
||||||
|
// Not collecting a log line
|
||||||
prevLine = line.toLowerCase();
|
prevLine = line.toLowerCase();
|
||||||
break;
|
} else if (state == 1) {
|
||||||
case 1: // collecting a logging line.
|
// collecting a logging line.
|
||||||
break;
|
} else if (state == 2) {
|
||||||
case 2: // We've collected the complete log line.
|
// We've collected the complete log line.
|
||||||
checkLine(file, sb.toString(), lineNumber, prevLine)
|
checkLine(file, sb.toString(), lineNumber, prevLine)
|
||||||
state = 0
|
state = 0
|
||||||
break;
|
} else {
|
||||||
default:
|
assert false
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
}
|
||||||
|
|
||||||
|
@InputFiles
|
||||||
|
FileCollection sourceFiles
|
||||||
|
|
||||||
|
ValidateLogCallsTask() {
|
||||||
|
// No explicit outputs (outputs always up to date).
|
||||||
|
outputs.upToDateWhen { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
def checkLogLines() {
|
def checkLogLines() {
|
||||||
|
sourceFiles.each { checkFile(it) }
|
||||||
project.sourceSets.each { srcSet ->
|
logger.warn("Checked: ${sourceFiles.files.size()}")
|
||||||
srcSet.java.each { f ->
|
|
||||||
checkFile(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errsFound > 0) {
|
if (errsFound > 0) {
|
||||||
throw new BuildException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
|
throw new BuildException(String.format(Locale.ENGLISH, 'Found %d violations in source files (%s).',
|
||||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
||||||
28b330c20a9a73881dfe9702df78d4d78bf72368e8906c70080ab6932462fe9e
|
70239e6ca1f0d5e3b2808ef6d82390cf9ad58d3a3a0d271677a51d1b89475857
|
|
@ -1 +1 @@
|
||||||
6.0.1
|
6.4.1
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
Loading…
Reference in New Issue