Gradle plugins integration tests code coverage with Jacoco plugin

I did get this to work, to ensure i always had the correct jacoco runtime available i added a configuration with the dependency and then wrote the correct org.gradle.jvmargs to the gradle.properties file before then running the build:

./gradlew setupJacocoProps
./gradlew integTest

etc

configurations {
jacocoRuntime
}

dependencies {
jacocoRuntime “org.jacoco:org.jacoco.agent:${jacoco.toolVersion}:runtime”
}

task setupJacocoProps << {
file(‘gradle.properties’).write(“org.gradle.jvmargs:-javaagent:${configurations.jacocoRuntime.asPath}=destfile=$buildDir/jacoco/testKit.exec”)
}

Hope this helps.

1 Like