浏览代码

Enable caching for Test tasks

Lóránt Pintér 7 年之前
父节点
当前提交
7b708bb4f5
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      build.gradle

+ 13 - 0
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
+		    }
+		}
+	}
+}