7

I am using Gradle 5.2, spotbugs-gradle-plugin version 2.0.0 and tried to generate SpotBugs report on my project. I used the following configuration on my project but it always create XML reports instead of html report.

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:+'
        classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0"
    }
}

allprojects {
    apply plugin: 'com.github.johnrengelman.shadow'
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'com.github.spotbugs'

    group = 'com.myproject'
    version = '1.0.0'

    repositories {
        mavenCentral()
    }

    dependencies {
        compile('com.google.cloud:google-cloud-storage:+') {
            exclude group: "com.google.guava", module: "guava"
        }
        compile group: 'org.apache.commons', name: 'commons-collections4', version: '+'
        compile group: 'com.google.guava', name: 'guava', version: '+'

        testImplementation('org.junit.jupiter:junit-jupiter:+')
    }

    test {
        useJUnitPlatform()
        testLogging {
            events "passed", "skipped", "failed"
        }
    }
}

project(':myproject') {
    dependencies {
        compile group: 'com.github.javafaker', name: 'javafaker', version: '+'
        compile group: 'org.jsonschema2pojo', name: 'jsonschema2pojo-core', version: '+'
        compile group: 'commons-lang', name: 'commons-lang', version: '+'
        compile group: 'org.mongodb', name: 'bson', version: '+'
    }
}

tasks.withType(JavaCompile) {
    options.compilerArgs << '-Xlint:unchecked'
    options.deprecation = true
}

spotbugsMain {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}

What I did wrong here?

Kindly provide your inputs to create HTML report instead of XML!

Lii
  • 11,553
  • 8
  • 64
  • 88
SST
  • 2,054
  • 5
  • 35
  • 65
  • 1
    You have `xml.enabled` and `html.enabled` both set to `true`, but you can't get simultaneous XML and HTML reports. See [Support xml and html reports at once #114](https://github.com/spotbugs/spotbugs-gradle-plugin/issues/114) and [Allow multiple output types #857](https://github.com/spotbugs/spotbugs/issues/857). Since setting both values to `true` makes no sense, try setting `xml.enabled = false`. Do you get an html report if you do that? – skomisa Oct 24 '19 at 04:12
  • 1
    Whatever I set its not generating html reports, always generating xml. – SST Oct 25 '19 at 04:22
  • Instead of _spotbugsMain_ try _task spotbugs_ like here: https://stackoverflow.com/questions/51191815/adding-spotbugs-to-my-project Or this one: https://github.com/wreulicke/spotbugs-gradle-plugin-issue32-reproduce/pull/1/commits/deba4477b1dbe4e955f1fc50cae83c4b20a16497 – salerokada May 31 '20 at 00:06

0 Answers0