spotbugs-gradle-plugin-multi-project-example

Created: 2019-01-06 01:56
Updated: 2019-01-26 22:44

README.md

spotbugs gradle multi-project build Build Status

Example of usage spotbugs-gradle-plugin (findbugs replacement) with HTML reports enabled in multi module Gradle project

config:

build.gradle file:

buildscript {
  ext {
    spotbugsVersion = '1.6.8'
    toolVersion = '3.1.10'
  }
}

plugins { 
  id 'com.github.spotbugs' version '1.6.8' apply false
}

apply from: "$rootProject.projectDir/gradle/spotbugs.gradle"

defaultTasks 'clean', 'check'

gradle/spotbugs.gradle file:

buildscript {
  repositories {
    maven { url "https://plugins.gradle.org/m2/" }
  }
  dependencies {
    classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:$spotbugsVersion"
  }
}

subprojects {
  apply plugin: "com.github.spotbugs"

  repositories {
    maven { url "https://plugins.gradle.org/m2/" }
  }

  spotbugs {
    toolVersion = project.toolVersion
    effort = "max"
    ignoreFailures = project.findProperty('ignoreBugs') != null
  }

  tasks.withType(com.github.spotbugs.SpotBugsTask) {
    reports {
      html {
        enabled = true
      }
      xml {
        enabled = false
      }
    }
  }
}

versions:

  • gradle: 5.1
  • spotbugs-gradle-plugin: 1.6.8
  • tool: 3.1.10

usage:

./gradlew               # to be failed
./gradlew -PignoreBugs  # do not failed on found bugs

links:

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more