Skip to content

Commit b822853

Browse files
committed
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
1 parent 0203652 commit b822853

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Diff for: build.gradle

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ ext {
4545
linkScmConnection = 'scm:git:git://github.com/spring-projects/spring-integration.git'
4646
linkScmDevConnection = 'scm:git:ssh://[email protected]:spring-projects/spring-integration.git'
4747

48-
modifiedFiles =
49-
providers.provider {
50-
files(grgit.status().unstaged.modified).filter { f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
51-
}
48+
modifiedFiles = !isCI
49+
? files(grgit.status().unstaged.modified).filter { f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
50+
: files()
5251

5352
apacheSshdVersion = '2.10.0'
5453
artemisVersion = '2.30.0'
@@ -293,7 +292,7 @@ configure(javaProjects) { subproject ->
293292

294293
tasks.register('updateCopyrights') {
295294
onlyIf { !isCI }
296-
inputs.files(modifiedFiles.map(files -> files.filter { f -> f.path.contains(subproject.name) }))
295+
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
297296
outputs.dir('build/classes')
298297

299298
doLast {

0 commit comments

Comments
 (0)