I am trying to generate reports using findbugs plugin for that i wrote below mentioned gradle script.I am setting the destination folder for reports but respective folder not get generated.So, how to solve this issue.
I can able to generate reports manually by using export button but i want generate from the gradle script.
Is it possible to generate reports from gradle script?
my gradle version - 2.2.1
task findbugs(type: FindBugs) {
ignoreFailures = true
effort = "max"
reportLevel = "high"
classes = files("${project.buildDir}/findbugs")
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = true
xml {
destination "$project.buildDir/reports/findbugs/findbugs.xml"
xml.withMessages true
}
}
classpath = files()
}
I managed to get to run findbugs with the newest gradle with the following gradle script snippet:
apply plugin: 'findbugs'
task customFindbugs(type: FindBugs) {
ignoreFailures = true
effort = "default"
reportLevel = "medium"
classes = files("$project.buildDir/intermediates/classes")
excludeFilter = file("$rootProject.rootDir/config/findbugs/exclude.xml")
source = fileTree('src/main/java/')
classpath = files()
reports {
xml.enabled = false
xml.withMessages = true
html.enabled = !xml.isEnabled()
xml.destination "$project.buildDir/outputs/findbugs/findbugs-output.xml"
html.destination "$project.buildDir/outputs/findbugs/findbugs-output.html"
}
}
// UPDATE: renamed the task to customFindbugs and made it automatically be called when build is called
build.dependsOn customFindbugs
My exclude.xml looks like the following:
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Class name="~.*Manifest\$.*"/>
</Match>
<Match>
<Class name="~.*_\$.*"/>
</Match>
</FindBugsFilter>
whereas the last check is used to omit classes generated by AndroidAnnotations and you most likely won't use this check...
After that I'm able to run the task by
./gradlew customFindbugs
or since the update of my code just by
./gradlew build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With