50

Using the Gradle FindBugs Plugin, how can I generate the output in HTML format??

The FindBugsExtension do have some config to set.

findbugs {
    toolVersion = "2.0.1"
    sourceSets = [sourceSets.main]
    ignoreFailures = true
    reportsDir = file("$project.buildDir/findbugsReports")
    effort = "max"
    reportLevel = "high"
    visitors = ["FindSqlInjection", "SwitchFallthrough"]
    omitVisitors = ["FindNonShortCircuit"]
    includeFilter = file("$rootProject.projectDir/config/findbugs/includeFilter.xml")
    excludeFilter = file("$rootProject.projectDir/config/findbugs/excludeFilter.xml")
}

But there is no output Properties to set as the findbugs anttask.

Lai
  • 1,320
  • 2
  • 13
  • 24

1 Answers1

91

Reports can only be configured on the FindBugs tasks. For example:

tasks.withType(FindBugs) {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}

The same holds for the other code quality plugins (Checkstyle, PMD, etc.).

Alice Purcell
  • 12,622
  • 6
  • 51
  • 57
Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • 1
    Thank you for the prompt response! Where can I find reference for this task? Is it stated somewhere in the official manual/reference? Also, is it possible to set a style file for generating the html? – Lai Mar 15 '13 at 03:28
  • 3
    All tasks are documented in the [Gradle Build Language Reference](http://gradle.org/docs/current/dsl/index.html). Sometimes you'll have to follow the links to the Javadoc/Groovydoc. It isn't possible to set a style file. – Peter Niederwieser Mar 15 '13 at 09:00
  • I dont have any such section for "PMD" and I see both reports (.xml and .html). Can you please clarify. – AKS Sep 12 '13 at 19:03
  • What do you mean by "I don't have such a section"? All you need to do is `tasks.withType(Pmd) { reports { ... } }`. – Peter Niederwieser Sep 12 '13 at 20:00
  • @PeterNiederwieser: Please have a look at http://stackoverflow.com/questions/29967309/findbugs-android-gradle-plugin? – Nevin Raj Victor May 04 '15 at 11:36
  • No html reports for checkstyle (Gradle 2.8) - https://docs.gradle.org/current/javadoc/index.html?org/gradle/api/plugins/quality/CheckstyleReports.html – Vijay Dev Oct 23 '15 at 14:41