O'Reilly logo

Apache Maven Cookbook by Raghuram Bharathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Analyzing code with the Maven FindBugs plugin

FindBugs is another tool that uses static analysis to inspect Java bytecode for bugs in a Java code. It is based on the concept of bug patterns. A bug pattern is a code snippet that is often an error.

How to do it...

Let us see how we can use the Maven FindBugs plugin to analyze and identify defects in our code:

  1. Open the Maven project for which you want to do the FindBugs analysis.
  2. Run the following command:
    mvn clean compile findbugs:findbugs
    
  3. Observe the output:
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project-with-violations ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 1 source file to C:\projects\apache-maven cookbook\project-with-violations\target\classes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required