Skip to content

Instantly share code, notes, and snippets.

@stevendick
Created January 22, 2012 17:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save stevendick/1657770 to your computer and use it in GitHub Desktop.
Save stevendick/1657770 to your computer and use it in GitHub Desktop.
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
Copy link

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