Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gradle & JaCoCo
task generateCoverageReport << {
ant {
taskdef(name:'jacocoreport', classname: 'org.jacoco.ant.ReportTask') {
classpath path: "${rootProject.projectDir.path}/lib/jacocoant.jar"
}
mkdir dir: "${buildDirName}/reports/coverage"
jacocoreport {
executiondata {
fileset(dir: "${buildDirName}/coverage-results") {
ant.file file: 'jacoco.exec'
}
}
structure(name: project.name) {
classfiles {
fileset dir: "${project.buildDir.path}/classes/main"
}
// this is for Windows
sourcefiles(encoding: 'CP1252') {
fileset dir: "${project.projectDir.path}/src/main/java"
}
}
xml destfile: "${buildDirName}/reports/coverage/jacoco.xml"
html destdir: "${buildDirName}/reports/coverage"
}
}
}
dependencies {
codeCoverage files("${rootProject.projectDir.path}/lib/jacocoagent.jar")
}
test {
jvmArgs "-javaagent:${configurations.codeCoverage.singleFile}=destfile=${buildDirName}/coverage-results/jacoco.exec,sessionid=HSServ,append=false",
'Djacoco=true',
'-Xms128m',
'-Xmx512m',
'-XX:MaxPermSize=128m'
}
@centic9

This comment has been minimized.

Copy link

@centic9 centic9 commented Sep 27, 2012

how does this compare to https://github.com/gschmidl/jacoco-gradle ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment