1. Use of MVN Checkstyle plugin
You can get Checkstyle reports on target/site/checkstyle.html and target/without any setup, directly running MVN checkstyle:checkstyle Checkstyle-result.xml. The check rule for the Checkstyle used is Sun_checks.xml-sun Microsystems Definition (default).
If you want to use custom rules, the version above maven3.0 needs to be added under the Pom.xml <build> tag to add Checkstyle plugin settings, and can not be used on the official web site Pom.xml in <reporting > Label settings:
<reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> < Artifactid>maven-checkstyle-plugin</artifactid> <version>2.17</version> <configuration > <configLocation>checkstyle.xml</configLocation> </configuration> </plugin> </ Plugins> </reporting>
And it should be
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<configLocation>YOUR_checkstyle.xml</configLocation>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
</plugins>
</build>
The above is for a single module project.
For project with multiple module, you need to make additional settings, refer to https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html
The same pom.xml added in the root directory
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.17</version>
+ <configuration>
+ <configLocation>rules/YOUR_checkstyle.xml</configLocation>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>com.example.build-tools</groupId>
+ <artifactId>build-tools</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
Then, at run time, use MVN compile-u checkstyle:checkstyle to find target/site/checkstyle.html and target/under each module Checkstyle-result.xml
of the results.
The other solution is as follows
http://rolf-engelhard.de/2013/07/using-a-custom-checkstyle-ruleset-on-a-maven-multi-module-project/
The same findbugs & PMD
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>3.6</version>
+ <configuration>
+ <rulesets>
+ <ruleset>pmd-rules.xml</ruleset>/Custom rule set
+ </rulesets>
+ </configuration>
+
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>3.0.3</version>
+ <configuration>
+ <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
Then run MVN compile-u findbugs:findbugs & mvn compile-u PMD:PMD