diff --git a/buildCacheSettings.gradle b/buildCacheSettings.gradle new file mode 100644 index 0000000000..b4d0175f6e --- /dev/null +++ b/buildCacheSettings.gradle @@ -0,0 +1,16 @@ +// Gradle Build Cache configuration recommendation: https://docs.gradle.org/current/userguide/build_cache.html +ext { + isCiServer = System.getenv().containsKey("CORDA_CI") + gradleBuildCacheURL = System.getenv().containsKey("GRADLE_BUILD_CACHE_URL") ? System.getenv().get("GRADLE_BUILD_CACHE_URL") : 'http://localhost:5071/cache/' +} + +buildCache { + local { + enabled = !isCiServer + } + remote(HttpBuildCache) { + enabled = isCiServer + url = gradleBuildCacheURL + push = isCiServer + } +} diff --git a/settings.gradle b/settings.gradle index bf61ba16cf..8f2543aebb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -122,24 +122,8 @@ include 'common-logging' project(":common-logging").projectDir = new File("$settingsDir/common/logging") // Common libraries - end +apply from: 'buildCacheSettings.gradle' include 'detekt-plugins' include 'tools:error-tool' -buildCache { - local { enabled = false } - remote(HttpBuildCache) { - url = "${gradleEnterpriseUrl}/cache/" - credentials { - username = settings.ext.find('BUILD_CACHE_CREDENTIALS_USR') ?: System.getenv('BUILD_CACHE_CREDENTIALS_USR') - password = settings.ext.find('BUILD_CACHE_CREDENTIALS_PSW') ?: System.getenv('BUILD_CACHE_CREDENTIALS_PSW') - } - if (System.getenv().containsKey("JENKINS_URL")) { - push = true - enabled = true - } else { - push = false - enabled = false - } - } -}