Disable caching of changing modules and dynamic versions

Previously, changing modules (snapshots) and dynamic versions were
cached for Gradle's default period of 24 hours and
--refresh-dependencies was used to pick up the latest artifacts. This
approach has a notable downside. --refresh-dependencies causes all
dependencies to be refreshed, irrespective of whether they are
expected to change. At a minimum, this results in a HEAD request for
every dependency in the build. Running an up-to-date build without
--refresh-dependencies takes in the region of 6 seconds:

$ ./gradlew build

BUILD SUCCESSFUL in 6s
203 actionable tasks: 203 up-to-date

The same build with --refresh-dependencies takes almost ten times as
long:

$ ./gradlew build --refresh-dependencies

BUILD SUCCESSFUL in 58s
203 actionable tasks: 203 up-to-date

This commit replaces the manual usage of --refresh-dependencies on
the command line with a 0 second caching period for changing modules
and dynamic versions. This should remove the need to use
--refresh-dependencies both locally and on CI, saving almost 1 minute
per full build.
This commit is contained in:
Andy Wilkinson 2019-09-10 17:12:55 +01:00 committed by Brian Clozel
parent 333711fd36
commit b730597c87
1 changed files with 7 additions and 1 deletions

View File

@ -299,6 +299,12 @@ configure(allprojects) { project ->
maven { url "https://repo.spring.io/milestone" } // Reactor maven { url "https://repo.spring.io/milestone" } // Reactor
} }
} }
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, "seconds"
cacheDynamicVersionsFor 0, "seconds"
}
}
} }
configure([rootProject] + javaProjects) { project -> configure([rootProject] + javaProjects) { project ->