Monday, October 05, 2009

Findbugs Filter Creation Tool

We have started using findbugs on some of the projects I am working on. It seems pretty useful, and it has picked out some bugs already. It does however, report quite a few bugs that are not a problem. Luckily, findbugs provides filters to be able to exclude the bugs you don't want to include.

After spending a day on creating the filter files manually, I found it to be a bit fiddly and time-consuming to create these by hand. I tried looking to see if there was a way to automate this a bit more. I might be wrong, but I could not find a tool to do this. Hopefully the below will help others in the same situation.

When you run a findbugs check it generates an output file. I do this via the maven plugin: mvn findbugs:check which yields a file called findbugsCheck.xml. This file references an xsl stylesheet:
<?xml-stylesheet type="text/xsl" href="http://findbugs.sourceforge.net/xsl/default.xsl"?>

so if you open this file in your browser you will see something like this:


I created another version of default.xsl called filterHelper.xsl. Modifying findbugsCheck.xml to use this stylesheet:
<?xml-stylesheet type="text/xsl" href="http://anonsvn.jboss.org/repos/jbossas/projects/findbugs-filtercreator/trunk/filterHelper.xsl"?>

gives output that looks much the same

Now each bug has a a checkbox next to it. Check the bugs you want to create an exclude filter for, press the "Create Filter" button and the textarea gets populated with the Match elements for each bug.

You can then copy the results into a file, in my projects they are under src/main/resources/findbugs/exclude.xml. For example:
<FindBugsFilter>
<Match>
<Class name="org.jboss.system.ServiceMBeanSupport"/>
<Field name="SERVICE_CONTROLLER_SIG"/>
<Bug pattern="MS_PKGPROTECT"/>
</Match>
<!-- Rest of exclusions here -->
</FindBugsFilter>

Then set maven up to use the filter in the plugins section:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<excludeFilterFile>${project.build.outputDirectory}/findbugs/exclude.xml</excludeFilterFile>
<debug>true</debug>
</configuration>
</plugin>

Wednesday, May 27, 2009

Microcontainer Downloads

While getting up to speed after joining the JBoss Microcontainer project, I have updated our downloads section with the latest releases.

The old JBoss Microcontainer 1.0.x releases can still be found on Sourceforge. Since those early releases were uploaded the JBoss Microcontainer has developed a lot, and it is now the umbrella for several sub-projects.

The downloads section has been split into two main categories:

  • The Frameworks category contains the downloads most convenient for end users:

    • Kernel: This is what most people think of when they hear "Microcontainer". It contains the core of the Microcontainer and its dependencies. In brief this is the core state machine with the dependency injection framework, with support for bean metadata supplied via xml or annotations.

    • JBoss Virtual Deployment Framework: This contains all the individual projects from the JBoss Microcontainer project. It consists of the Kernel, advanced classloading capabilities and deployment support, as consumed by JBoss Application Server and JBoss Reloaded.



  • The Individual Projects section contains the independent releases of the JBoss Microcontainer sub-projects. Only the binaries and sources are currently contained in the downloads, with no dependencies. The sources are however buildable using maven (version 2.0.9 or later), so you can get all the dependencies and javadoc.



The current releases on the downloads pages take the already released latest releases of the MC projects. Over the next few releases the plan is to put in a lot of effort in improving our consumables.