From fe5d0affdebb2236a139d3cf5ca481dac620b76e Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 14 Feb 2019 10:39:50 -0500 Subject: [PATCH] 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 --- build.gradle | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index a00ae9412f..d89942b2d9 100644 --- a/build.gradle +++ b/build.gradle @@ -192,22 +192,22 @@ subprojects { subproject -> [compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg] task checkTestConfigs { - def configFiles = [] - sourceSets.test.java.srcDirs.each { - fileTree(it).include('**/*.xml').exclude('**/log4j2-test.xml').each { configFile -> - def configXml = new XmlParser(false, false).parse(configFile) - - if (configXml.@'xsi:schemaLocation' ==~ /.*spring-[a-z-]*\d\.\d\.xsd.*/) { - configFiles << configFile - } - } - } - inputs.files(configFiles) + inputs.files( + sourceSets.test.java.srcDirs.collect { + fileTree(it) + .include('**/*.xml') + .exclude('**/log4j2-test.xml') + }) outputs.dir('build') doLast { - if (!inputs.files.empty) { + def wrongConfigs = inputs.files.filter { + new XmlParser(false, false) + .parse(it) + .@'xsi:schemaLocation' ==~ /.*spring-[a-z-]*\d\.\d\.xsd.*/ + } + if (!wrongConfigs.empty) { throw new InvalidUserDataException('Hardcoded XSD version in the config files:\n' + - inputs.files.collect {relativePath(it) }.join('\n') + + wrongConfigs.collect { relativePath(it) }.join('\n') + '\nPlease, use versionless schemaLocations for Spring XSDs to avoid issues with builds ' + 'on different versions of dependencies.') }