MVN CHECKSTYLE/FINDBUGS/PMD Plug-ins Use

Source: Internet
Author: User
Tags checkstyle

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.