Aggregate report of findbugs or pmd reports

I’ve tried a couple different ways to get an aggregate report of FindBugs (or PMD) reports. I have a multi project build and I would like to aggregate the reports of all the subprojects into one report. Attempt using TestReport task (runs the findbugs tasks, but skips the aggregate task saying onlyIf is false. I think that the reportOn doesn’t know what to do with the FindBugs task or the report files.):

def getFindBugsTasks() {
    allprojects.collect { it.tasks.withType(FindBugs) }.flatten()
  def getAllFindBugsReports() {
  task aggregateFindBugsReport(type: TestReport) {
    destinationDir = file("$buildDir/reports/findbugs")
    reportOn {

Attempt creating custom task using DefaultTestReport (fails saying could not determine dependencies of the task):

task aggregateFindBugsReports(type: TestReportAggregator) {
    testReportDir = file("${reporting.baseDir}/findBugs")
    testResultsDir = file("${buildDir}/test-results")
    projects = subprojects
import org.gradle.api.internal.tasks.testing.junit.result.AggregateTestResultsProvider
  class TestReportAggregator extends Copy {
    def projects
      File testResultsDir
    File testReportDir
      def TestReportAggregator() {
        dependsOn { findBugsTasks }
        from { inputTestResultDirs }
        into { testResultsDir }
    def aggregate() {
        def report = new DefaultTestReport()
        report.generateReport(new AggregateTestResultsProvider(findBugsTasks), testReportDir)
      def getFindBugsTasks() {
        projects.collect { it.tasks.withType(FindBugs) }.flatten()
      def getInputTestResultDirs() {
      def getAllFindBugsReports() {
        def list = []
        findBugsTasks.each {
            list << it.reports.html.destination

Hey jeremy,

would you mind to use ‘code’ tags in the future to format your code?

There is no easy way to do an aggregation of those reports. Findbugs does not ship with a aggregation task I think. One option is to create an FindBugsReportAggregationTask that uses xslt to convert multiple xml reports into one report. We’re currently working on a buildDashboard plugin that contains an build-report containing links to all build related reports (test, findbugs, pmd, …). It’s not yet finished, but you can give it a shot. feedback welcome.



You could try creating a fat FindBugs task in a root project and configure this task with classpaths from all FindBugs tasks in child projects. It’s not aggregation but rather running one fat findbugs execution on all classes at once.