From 1d68cea844faafd5801f01d495022b691fe61cea Mon Sep 17 00:00:00 2001 From: Oleg Golberg Date: Thu, 7 Sep 2023 09:55:08 -0400 Subject: [PATCH] Enable configuration caching and fix testkit jacoco aggregation --- gradle.properties | 3 ++- plugin/build.gradle.kts | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 29e08e8..43b52ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -kotlin.code.style=official \ No newline at end of file +org.gradle.caching=true +#org.gradle.configuration-cache=true diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 5def62f..a0a28f0 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -21,8 +21,24 @@ tasks { val jacoco = project.zipTree(configurations.getByName("jacocoAgent").asPath).filter { it.name == "jacocoagent.jar" }.singleFile - val destfile = layout.buildDirectory.file("jacoco/test.exec").get() + + val destfile = layout.buildDirectory.file("jacoco/testkit.exec").get() + // declare an additional jacoco output file so that the JUnit JVM and the TestKit JVM + // do not try to write to the same file + outputs.file(destfile).withPropertyName("testkit-jacoco") + systemProperty("testkit-javaagent", "$jacoco=destfile=$destfile") + + // add the TestKit jacoco file to outgoing artifacts so that it can be aggregated + configurations.getAt("coverageDataElementsForTest").outgoing.artifact(destfile) { + type = ArtifactTypeDefinition.BINARY_DATA_TYPE + builtBy("test") + } + } + + jacocoTestReport { + // add the TestKit jacoco file to the local jacoco report + this.executionData.from(layout.buildDirectory.dir("jacoco").map { files("test.exec", "testkit.exec") }) } }