From 7b708bb4f54e9b1bee7d320225911e02eaf93451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3r=C3=A1nt=20Pint=C3=A9r?= Date: Thu, 1 Feb 2018 11:56:23 +0100 Subject: [PATCH] Enable caching for Test tasks --- build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index ab946b6106..27efb6a325 100644 --- a/build.gradle +++ b/build.gradle @@ -17,3 +17,16 @@ ext.releaseBuild = version.contains("SNAPSHOT") ext.milestoneBuild = !(snapshotBuild || releaseBuild) dependencyManagementExport.projects = subprojects.findAll { !it.name.contains('-boot') } + +// Disable JaCoCo when not explicitly requested to enable caching of test +// See https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504 +gradle.taskGraph.whenReady { graph -> + def enabled = graph.allTasks.any { it instanceof JacocoReport } + subprojects { project -> + project.plugins.withType(JacocoPlugin) { + project.tasks.withType(Test) { + jacoco.enabled = enabled + } + } + } +}