Files
apollo/gradle/jacoco.gradle
T
Gary Tierney 0651d535fa Update to Kotlin 1.60 and Gradle 4.9
Removes the dependency on legacy script compilation and now relies on script
discovery.  In addition, the Gradle build scripts were refactored and updated
to be compatible with Gradle 5.0 and make use of the new java-library
configurations.
2018-08-19 19:26:51 +01:00

59 lines
1.5 KiB
Groovy

apply plugin: "jacoco"
allprojects {
tasks.withType(Test) {
jacoco {
toolVersion = '0.8.1'
}
afterEvaluate {
jacocoTestReport {
dependsOn tasks.test
sourceSets sourceSets.main
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
}
}
task jacocoTestReport(type: JacocoReport) {
sourceDirectories = files()
classDirectories = files()
executionData = files()
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
// Work-around to allow us to build list of executionData files in doFirst
onlyIf = {
true
}
/*
* Builds list of source dirs, class dirs, and executionData files
* when task is run, not at script evaluation time
*/
doFirst {
subprojects.findAll { subproject ->
subproject.pluginManager.hasPlugin('java')
}.each { subproject ->
additionalSourceDirs files((Set<File>) subproject.sourceSets.main.allJava.srcDirs)
additionalClassDirs((FileCollection) subproject.sourceSets.main.output)
if (subproject.pluginManager.hasPlugin('jacoco')) {
executionData subproject.tasks.jacocoTestReport.executionData
}
}
executionData = files(executionData.findAll {
it.exists()
})
}
}