[External Analyzer Reports] Report generation for Java / Maven

If you’re a Maven user, automatically generating external issues reports is easy:

  1. Open your pom.xml and in the section add the following plugins:

    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-pmd-plugin</artifactId>
       <version> 3.10 . 0 </version>
    </plugin>
    <plugin>
       <groupId>com.github.spotbugs</groupId>
       <artifactId>spotbugs-maven-plugin</artifactId>
       <version> 3.1 . 1 </version>
       <configuration>
         <effort>Max</effort>
         <threshold>Low</threshold>
         <failOnError> true </failOnError>
         <includeFilterFile>${session.executionRootDirectory}/spotbugs-include.xml</includeFilterFile>
         <plugins>
           <plugin>
             <groupId>com.h3xstream.findsecbugs</groupId>
             <artifactId>findsecbugs-plugin</artifactId>
             <version>LATEST</version> <!-- Auto-update to the latest stable -->
           </plugin>
         </plugins>
       </configuration>
    </plugin>
    
  2. Add or update the section with:

    <properties>
      <sonar.java.spotbugs.reportPaths>./target/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
      <sonar.java.pmd.reportPaths>./target/pmd.xml</sonar.java.pmd.reportPaths>`
      <sonar.java.checkstyle.reportPaths>./target/checkstyle-result.xml</sonar.java.checkstyle.reportPaths>
    </properties>
    
  3. Execute:

    mvn clean package spotbugs:spotbugs pmd:pmd checkstyle:checkstyle sonar:sonar
    
1 Like