idea安装checkstyle

2018-06-13  本文已影响0人  phoebe_gyq

参考资料:

https://www.jianshu.com/p/0c917f4cac1e

https://www.jianshu.com/p/25d2a197a59a

1. 安装插件

Settings->Plugins里,搜索Checkstyle,并且install安装

2.

image.png

3. 引入xml配置(在本地路径中下载好的,jenkins官网可下载 image.png


image.png

4. 自定义颜色

image.png

5. maven执行检查

<groupId>jenkinsTest</groupId>
    <artifactId>jenkins</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.17</version>
                <configuration>
                    <configLocation>google_checks.xml</configLocation>
                    <encoding>UTF-8</encoding>
                    <failOnViolation>true</failOnViolation>
                    <linkXRef>false</linkXRef>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    <maxAllowedViolations>0</maxAllowedViolations>
                    <violationSeverity>warning</violationSeverity>
                </configuration>
                <executions>
                    <execution>
                        <id>checkstyle</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>8.10.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.17</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>checkstyle</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
Goal Report or Not Description
checkstyle:check No 检查代码,并可能导致构建失败
checkstyle:checkstyle Yes 检查代码并生成代码检查结果报表
checkstyle:checkstyle-aggregate Yes 对多模块的项目代码检查,并生产检查汇总的结果报表 image.png
上一篇下一篇

猜你喜欢

热点阅读