Software quality in Java all together
I have published a few posts on how to use the most popular Java frameworks to keep your project’s quality under control:
Since all these frameworks support Maven plugins, I’d like to put them all together
in a pom.xml
file just to facilitate the configuration to anyone that might
find it useful. If you want to download the files directly just click on this Gist.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.36</version>
</dependency>
</dependencies>
<configuration>
<!-- sun_checks.xml, google_checks.xml or any other-->
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<!-- failOnViolation is actually true by default, but can be disabled -->
<failOnViolation>true</failOnViolation>
<!-- printFailingErrors is pretty useful -->
<printFailingErrors>true</printFailingErrors>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.1.4</version>
<dependencies>
<!-- overwrite dependency if you want to specify the version of SpotBugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.1.4</version>
</dependency>
</dependencies>
<configuration>
<xmlOutput>true</xmlOutput>
<!-- Optional directory to put spotbugs xdoc xml report -->
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
<executions>
<execution>
<id>default-report</id>
<phase>verify</phase> <!-- this the default phase-->
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>