Thursday, November 25, 2010

Run FindBugs from your Eclipse RCP headless build

Running FindBugs from Eclipse RCP headless build is pretty much simple:

1. Add the following target to your customTargets.xml (replace "com.yourcompany" with your package/plug-in prefix):



  
  
  
  
    
      
    
  
  
  
  
    
      
      
    
  

  
  
    
      
    
  

  
  
    
      
    
    
  

  
  

    
      
        
      
    
  

  
  
   
    
    
    
  


2. Create input filter file (findbugs-filter.xml):


  
    
  


3. Invoke "findbugs" target from the "prePackage" target:



  
  
  
  
  
    
      


4. Make sure environment variable FINDBUGS_HOME points to the installation of FindBugs.

5. (For Hudson users) Install, and configure FindBugs plug-in to get the fancy "bugs" trend graph :-)

5 comments:

Anonymous said...

Hi Michael,
Instead of doing this in the customTargets.xml, individual bundles can use customBuildCallbacks.xml. This xml file provides a number of callbacks at various points of building your plug-in.

If you override the post.compile.@dot (post.compile.library.jar for nested jars) target, the .class files will be on disk located at ${target.folder}. The source code is under ${basedir} (the root of your bundle) and you have a reference to the classpath used to compile the classes (refid="@dot.classpath" or "library.jar.classpath").

This saves you from unzipping all the jars from the p2 repo. Also, it works during both headless build and export from the UI.

Unknown said...

Sorry, I also forgot there are references to the specific source folders in each library using ${source.folder1}, ${source.folder2), ...

Michael said...

@aniefer, I should try this approach as well. Thanks!

Scratsh said...

I'm currently trying to integrate FIndbugs in our PDE build following your post and the comment of Andrew.

Did you already tried with his advice?

Regards

Michael said...

@Scratsh, no I haven't tried. My simple solution works well for me, though not very optimized.