Skip to content

Commit fe5d0af

Browse files
committed
Optimize checkTestConfigs task for UP_TO_DATE
We really don't need to parse `inputs.files` for wrong XSD configuration. This is already a responsibility of the task. There is just enough to track changes in the XML configs and if they happened only after that treat the task as out of date and parse configs for wrong XSD configuration
1 parent 1fad620 commit fe5d0af

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

build.gradle

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,22 @@ subprojects { subproject ->
192192
[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg]
193193

194194
task checkTestConfigs {
195-
def configFiles = []
196-
sourceSets.test.java.srcDirs.each {
197-
fileTree(it).include('**/*.xml').exclude('**/log4j2-test.xml').each { configFile ->
198-
def configXml = new XmlParser(false, false).parse(configFile)
199-
200-
if (configXml.@'xsi:schemaLocation' ==~ /.*spring-[a-z-]*\d\.\d\.xsd.*/) {
201-
configFiles << configFile
202-
}
203-
}
204-
}
205-
inputs.files(configFiles)
195+
inputs.files(
196+
sourceSets.test.java.srcDirs.collect {
197+
fileTree(it)
198+
.include('**/*.xml')
199+
.exclude('**/log4j2-test.xml')
200+
})
206201
outputs.dir('build')
207202
doLast {
208-
if (!inputs.files.empty) {
203+
def wrongConfigs = inputs.files.filter {
204+
new XmlParser(false, false)
205+
.parse(it)
206+
.@'xsi:schemaLocation' ==~ /.*spring-[a-z-]*\d\.\d\.xsd.*/
207+
}
208+
if (!wrongConfigs.empty) {
209209
throw new InvalidUserDataException('Hardcoded XSD version in the config files:\n' +
210-
inputs.files.collect {relativePath(it) }.join('\n') +
210+
wrongConfigs.collect { relativePath(it) }.join('\n') +
211211
'\nPlease, use versionless schemaLocations for Spring XSDs to avoid issues with builds ' +
212212
'on different versions of dependencies.')
213213
}

0 commit comments

Comments
 (0)