Skip to content

Commit 239d619

Browse files
committed
Print report
1 parent 2cf7437 commit 239d619

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

build.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,28 @@ allprojects {
107107
it.dependsOn = []
108108
}
109109

110-
tasks.withType(FindBugs) {
111-
it.dependsOn = []
112-
}
113-
114110
findbugs {
115-
// toolVersion = "2.0.1"
116111
sourceSets = [sourceSets.main]
117112
excludeFilter = new File(rootDir, "findBugsSuppressions.xml")
118113
effort = "max"
119114
}
120115

116+
task checkFindBugsReport << {
117+
try {
118+
def xmlReport = findbugsMain.reports.getXml()
119+
def slurped = new XmlSlurper().parse(xmlReport.destination)
120+
def bugsFound = slurped.BugInstance.size()
121+
if (bugsFound > 0) {
122+
new XmlNodePrinter().printList(slurped.BugInstance.list())
123+
throw new GradleException("$bugsFound FindBugs rule violations were found. See the report at: $xmlReport.destination")
124+
}
125+
} catch (Exception e) {
126+
127+
}
128+
}
129+
130+
findbugsMain.finalizedBy checkFindBugsReport
131+
121132
repositories {
122133
mavenCentral()
123134
jcenter()

0 commit comments

Comments
 (0)