Skip to content

Commit

Permalink
Optimize updateCopyrights Gradle task
Browse files Browse the repository at this point in the history
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
  • Loading branch information
artembilan committed Oct 10, 2023
1 parent 0203652 commit b822853
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ ext {
linkScmConnection = 'scm:git:git://github.com/spring-projects/spring-integration.git'
linkScmDevConnection = 'scm:git:ssh://[email protected]: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'
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b822853

Please sign in to comment.