diff --git a/.ci/ci-gradle-build-cache-init.sh b/.ci/ci-gradle-build-cache-init.sh new file mode 100755 index 0000000000..1b076beb0d --- /dev/null +++ b/.ci/ci-gradle-build-cache-init.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export GRADLE_BUILD_CACHE_URL="${GRADLE_BUILD_CACHE_URL:-http://localhost:5071/cache/}" +export USE_GRADLE_DAEMON="${USE_GRADLE_DAEMON:-false}" +export GRADLE_CACHE_DEBUG="${GRADLE_CACHE_DEBUG:-false}" +export PERFORM_GRADLE_SCAN="${PERFORM_GRADLE_SCAN:---scan}" + +# cd %teamcity.build.checkoutDir% +echo "Using Gradle Build Cache: $GRADLE_BUILD_CACHE_URL" \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6283e44342..d4a6733558 100644 --- a/build.gradle +++ b/build.gradle @@ -120,6 +120,7 @@ plugins { // Add the shadow plugin to the plugins classpath for the entire project. id 'com.github.johnrengelman.shadow' version '2.0.4' apply false + id "com.gradle.build-scan" version "1.16" } ext { @@ -204,6 +205,12 @@ allprojects { if (project.path.startsWith(':experimental') && System.getProperty("experimental.test.enable") == null) { enabled = false } + + // Required to use Gradle build cache (until Gradle 5.0 is released with default value of "append" set to false) + // See https://github.com/gradle/gradle/issues/5269 and https://github.com/gradle/gradle/pull/6419 + extensions.configure(TypeOf.typeOf(JacocoTaskExtension)) { ex -> + ex.append = false + } } group 'net.corda' @@ -438,3 +445,8 @@ wrapper { gradleVersion = "4.10.1" distributionType = Wrapper.DistributionType.ALL } + +buildScan { + termsOfServiceUrl = 'https://gradle.com/terms-of-service' + termsOfServiceAgree = 'yes' +} \ No newline at end of file diff --git a/buildCacheSettings.gradle b/buildCacheSettings.gradle new file mode 100644 index 0000000000..fcfc1513bf --- /dev/null +++ b/buildCacheSettings.gradle @@ -0,0 +1,15 @@ +// 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) { + url = gradleBuildCacheURL + push = isCiServer + } +} diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index c46d96de90..2449091bd9 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -1,2 +1,4 @@ rootProject.name = 'buildSrc' include 'canonicalizer' + +apply from: '../buildCacheSettings.gradle' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 59e65ce554..0c6bf2d49f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ kotlin.incremental=true -org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g +org.gradle.jvmargs=-XX:+UseG1GC -Xmx1g -Dfile.encoding=UTF-8 +org.gradle.caching=true diff --git a/settings.gradle b/settings.gradle index 596d28d790..026a092f27 100644 --- a/settings.gradle +++ b/settings.gradle @@ -60,6 +60,8 @@ include 'samples:cordapp-configuration' include 'samples:network-verifier' include 'serialization' +apply from: 'buildCacheSettings.gradle' + if (JavaVersion.current() == JavaVersion.VERSION_1_8) { include 'core-deterministic' include 'core-deterministic:testing'