From b730597c876c29d10d24244d8621b31cd8b8e2b3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 10 Sep 2019 17:12:55 +0100 Subject: [PATCH] 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. --- build.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 39bcf23d458..2058b08b6b5 100644 --- a/build.gradle +++ b/build.gradle @@ -279,7 +279,7 @@ configure(allprojects) { project -> dependency "javax.xml.ws:jaxws-api:2.3.1" dependency "org.eclipse.persistence:javax.persistence:2.2.0" - + // Substitute for "javax.management:jmxremote_optional:1.0.1_04" which // is not available on Maven Central dependency "org.glassfish.external:opendmk_jmxremote_optional_jar:1.0-b01-ea" @@ -299,6 +299,12 @@ configure(allprojects) { project -> maven { url "https://repo.spring.io/milestone" } // Reactor } } + configurations.all { + resolutionStrategy { + cacheChangingModulesFor 0, "seconds" + cacheDynamicVersionsFor 0, "seconds" + } + } } configure([rootProject] + javaProjects) { project ->