Search code examples
javajdeveloperfindbugsspotbugs

Spotbugs integration with JDeveloper


I am a build engineer and my development team develops code in Jdeveloper IDE. Is there any way to integrate spotbugs directly in Jdeveloper and find the bugs?


Solution

  • For JDeveloper 12c, you can integrate spotbugs using Maven which is available by default into the IDE (You can also set it up for an 11g version but it's not integrated by default into the IDE) :

    <plugin>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-maven-plugin</artifactId>
      <version>3.1.12</version>
      <dependencies>
        <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
        <dependency>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs</artifactId>
          <version>4.0.0-beta3</version>
        </dependency>
      </dependencies>
    </plugin>
    

    For JDeveloper 11g, you can integrate spotbugs using Ant which is available by default into the IDE :

    <property name="spotbugs.home" value="/export/home/daveho/work/spotbugs" />
    
    <target name="spotbugs" depends="jar">
      <spotbugs home="${spotbugs.home}"
                output="xml"
                outputFile="bcel-sb.xml" >
        <auxClasspath path="${basedir}/lib/Regex.jar" />
        <sourcePath path="${basedir}/src/java" />
        <class location="${basedir}/bin/bcel.jar" />
      </spotbugs>
    </target>
    

    Read more : https://spotbugs.github.io/

    In both case you'll see the newly created spotbug task in the "build" menu inside jdeveloper