ghidra/gradleScripts/setupJacoco.gradle
2019-03-26 13:46:51 -04:00

40 lines
1.7 KiB
Groovy

/*********************************************************************************
* Configuration for jacoco tasks.
*********************************************************************************/
// 'jacocoEnabled' will enable jacocoMerge, jacocoBranchReport and jacocoReport if these tasks are
// specified on the cmd line.
// Applying jacoco plugin will create coverage files for each java Test task. This extra analysis
// slows down the overall Test task, so only enable jacoco when specified on the cmd line.
project.ext.jacocoEnabled = (project.gradle.startParameter.taskNames.contains('jacocoMerge') ||
project.gradle.startParameter.taskNames.contains('jacocoBranchReport') ||
project.gradle.startParameter.taskNames.contains('jacocoReport'))
// Apply jacoco plugin to root and subprojects. This will create coverage files for each java Test task.
if (jacocoEnabled) {
allprojects {
apply plugin:'jacoco'
dependencies {
jacocoAnt 'org.jacoco:org.jacoco.ant:0.8.2'
jacocoAgent 'org.jacoco:org.jacoco.agent:0.8.2'
}
}
}
subprojects {
// Clean any jacoco files that may have been left behind previously.
clean {
doFirst{
logger.debug("Deleting subproject jacoco execution data directory: $buildDir/jacoco/")
file("$buildDir/jacoco/").deleteDir() // delete jacoco executionData files in individual subprojects
logger.debug("Deleting root project jacoco execution data directory: $rootProject.buildDir/jacoco/")
file("$rootProject.buildDir/jacoco/").deleteDir() // delete jacocoMerge task output
logger.debug("Deleting jacoco report directory: $rootProject.buildDir/reports/jacoco/")
file("$rootProject.buildDir/reports/jacoco/").deleteDir() // delete jacocoReport, jacocoBranchReport output
}
}
}