Skip to content

Instantly share code, notes, and snippets.

@ksperling
Created January 19, 2016 01:57
Show Gist options
  • Save ksperling/57b81ea723e319967d24 to your computer and use it in GitHub Desktop.
Save ksperling/57b81ea723e319967d24 to your computer and use it in GitHub Desktop.
Multi-module JaCoCo report
// Runs a combined JaCoCo report across all modules in the reactor
// Output is placed in the root project's output directory
def root = session.topLevelProject
def modules = session.projectDependencyGraph.sortedProjects
.findAll { it != project && it.packaging != 'pom' }
if (!modules.empty) {
def jacoco = groovy.xml.NamespaceBuilder.newInstance(ant, 'antlib:org.jacoco.ant')
jacoco.report {
executiondata {
modules.collect { ant.fileset(file: new File(it.build.directory, "jacoco.exec")) }
}
structure(name: "Combined coverage") {
classfiles {
modules.collect { ant.fileset(dir: it.build.outputDirectory) }
}
sourcefiles {
modules.collectMany { it.compileSourceRoots.collect { ant.fileset(dir: it) } }
}
}
html(destdir: new File(root.build.directory, "jacoco"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment