From b8228531d57daec3fc4279c89ec3734c3aa81e0d Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 10 Oct 2023 17:27:08 -0400 Subject: [PATCH] Optimize `updateCopyrights` Gradle task Turns out the `providers.provider` does not cache its value and `grgit.status()` is called for every `updateCopyrights` task in sub-modules * Bring back regular `modifiedFiles` property, but guard it with a `!isCI` condition to avoid the `grgit.status()` call on CI --- build.gradle | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index edc585986a7..a6f31c4f4d3 100644 --- a/build.gradle +++ b/build.gradle @@ -45,10 +45,9 @@ ext { linkScmConnection = 'scm:git:git://github.com/spring-projects/spring-integration.git' linkScmDevConnection = 'scm:git:ssh://git@github.com:spring-projects/spring-integration.git' - modifiedFiles = - providers.provider { - files(grgit.status().unstaged.modified).filter { f -> f.name.endsWith('.java') || f.name.endsWith('.kt') } - } + modifiedFiles = !isCI + ? files(grgit.status().unstaged.modified).filter { f -> f.name.endsWith('.java') || f.name.endsWith('.kt') } + : files() apacheSshdVersion = '2.10.0' artemisVersion = '2.30.0' @@ -293,7 +292,7 @@ configure(javaProjects) { subproject -> tasks.register('updateCopyrights') { onlyIf { !isCI } - inputs.files(modifiedFiles.map(files -> files.filter { f -> f.path.contains(subproject.name) })) + inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) }) outputs.dir('build/classes') doLast {