Wednesday Dec 28, 2011

FindBugs integration with JDeveloper

Picking up from yesterday's post about using the External Tools->Ant Operation to integrate third party utilities into JDeveloper, here is a quick entry that shows how to integrate the FindBugs utility in a similar way. (You should probably watch the Checkstyle video first).

First get findBugs and extract it onto your hard drive (in my case I extracted it to C: to get the folder C:/findbugs-2.0.0.

Then in that directory I created the following ant build file:

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="antlib:org.apache.tools.ant" default="init">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
  <target name="init">
    <tstamp/>
  </target>
  <property name="findbugs.home" value="C:/findbugs-2.0.0" />
  <target name="findbugs">
    <findbugs home="${findbugs.home}" output="text">   
      <sourcePath path="${basedir2}/src/java" />
      <class location="${basedir2}/classes" />
    </findbugs>
  </target>
</project>

When you create the External Tools -> Ant operation you'll point to that file and choose the findbugs operation. You then define basedir2 as a property of the Ant operation and uses the ${project.dir} value in JDeveloper. And you can then have this operation in your tools menu. Don't forget to add the  C:\findbugs-2.0.0\lib\findbugs-ant.jar file to your Ant Classpath in step 6 of the external tools wizard.

Since FindBugs scans your classes you should first compile your project, then to run just stand on a file in your project and choose the findbugs operation in your tools menu - this will scan the full project and report the suspected bugs in your Ant log window.

Something like this:


About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today