转载注意出处:http://blog.csdn.net/hwhua1986/article/details/48339545

by  whhuang

Maven官方配置说明:http://maven.apache.org/plugins/maven-checkstyle-plugin/

一、Pom的配置

备注:pom.xml是maven项目必备的构建文件。

1、  在<build>里增加checkstyle的配置


代码如下:

                     <plugin>

                       <groupId>org.apache.maven.plugins</groupId>

                       <artifactId>maven-checkstyle-plugin</artifactId>

                        <version>2.16</version>

                        <executions>

                             <execution>

                               <id>validate</id>

                               <phase>validate</phase>

                               <configuration>

                                    <configLocation>checkstyle.xml</configLocation>

                                    <encoding>UTF-8</encoding>

                                    <consoleOutput>true</consoleOutput>

                                    <failsOnError>true</failsOnError>

                                    <linkXRef>false</linkXRef>

                               </configuration>

                               <goals>

                                    <goal>check</goal>

                               </goals>

                             </execution>

                        </executions>

                      </plugin>

2、  在<reporting>里增加checkstyle的报告生存配置


代码如下:

                     <plugin>

                            <groupId>org.apache.maven.plugins</groupId>

                            <artifactId>maven-checkstyle-plugin</artifactId>

                            <version>2.16</version>

                            <configuration>

                              <configLocation>checkstyle.xml</configLocation>

                            </configuration>

                     </plugin>

 

二、Jenkins的Job配置

1、安装插件Checkstyle Plug-in


2、新建一个job


3、配置svn地址


4、增加构建步骤


5、增加构建后步骤Publish Checkstyle analysis results,默认设置即可。

 

6、查看检查报告


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐