Findbugs plugin, file exclusion feature and misc remarks

Some remarks, and some questions related to the findbugs plugin :

  1. Remark : The ‘excludes’ property of the findbugs task does not work, because it excludes java sources from the ‘sourcePath’ property of the FindBugs Ant task. Problem is, the ‘sourcePath’ property is optional and does not drive the list of analyzed classes (it is simple there to gather source code information for the report). Actually, ‘classes’ is the real list

  2. Remark : Because of 1) I’ve tried to filter the list of analyzed classes with the ‘classes’ property :

findbugsMain.classes.exclude '**/foo/*'

This should work, because ‘classes’ is a ConfigurableFileTree, but it does not work because the exclude information is not properly propagated to the Ant task. However, I’ve found a workaround :

def
ft = findbugsMain.classes
ft.exclude '**/foo/*'
findbugsMain.classes = files(ft.files) // explicit list of files
  1. Question : All quality plugins have an ‘extension’ that allows to override the analyzed sourceSets. Let’s say that I want to analyse a sourceSet ‘foo’ that is a subset of my ‘main’ sourceSet. How can I create this new sourceSet ‘foo’ ? - I can not mutate the ‘main’ sourceSet because I still want all my classes to be compiled - I can not redefine a third ‘foo’ sourceSet in the ‘sourceSets’ of the project because the ‘main’ sourceSet and the ‘foo’ sourceSet would overlap (what would be the behavior of the compilation?) So, should I manually create a ‘foo’ sourceset ? To sum it up, is there an idiom associated to the existence of this extension ?

  2. Question : For the findBugs plugin, do you intend to add the ‘Filter’ feature that allows to deactivate some checks ?

  3. Remark : I think that the DSL documentation should explain how to activate the html report

[findbugsMain, findbugsTest]*.reports {
     xml.enabled false
     html.enabled true
 }

(I’ve found this in the integration test of the plugin, but when you don’t know it, it is not a slam dunk)

Thank you

To answer one of your questions, “mutating” methods on a source set return a new source set backed by the old one. So you can safely call methods like ‘matching’ on an existing source set, without having to fear that this source set will change.

Over time we’ll add additional configuration options for all of the code quality plugins. So far we just focused on getting the core design right.