mvn Checkstyle使用
来源:互联网 发布:淘宝花呗分期怎么开通 编辑:程序博客网 时间:2024/06/16 11:07
Usage
The following examples describe the basic usage of the Checkstyle Plugin.
Generate Checkstyle Report As Part of the Project Reports
To generate the Checkstyle report as part of the Project Reports, add the Checkstyle Plugin in the <reporting> section of your pom.xml.
- <project>
- ...
- <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>
- ...
- </project>
Then, execute the site phase to generate the report.
- mvn site
Generate Checkstyle Report As Standalone
You can also generate the Checkstyle report by explicitly executing the checkstyle:checkstyle goal from the command line. You are not required to specify the Checkstyle Plugin in your pom.xml unless you want to use a specific configuration.
- mvn checkstyle:checkstyle
Checking for Violations as Part of the Build
If you want to report to the console or fail the build, you must add an execution of checkstyle::check to the <build> element and configure any options that you need.
(Note in that for Maven 3, as per Maven 3 Compatibility Notes, in Maven 3, options you set in the <reporting> element do not have any effect on executions in the <build> element.)
Note that the phase that checkstyle::check is bound to is very important. If bound to the validate phase, it would check the code prior to compiling the code. If the code is invalid, the parsing errors reported by checkstyle may be different than what would be expected from the javac compiler. However, it's guaranteed to run. Another popular option is to bind it to the verify phase which would run much later (and allow the javac compiler to flag invalid code prior to checkstyle). However, if developers generally just use "mvn test" prior to pushing changes, checkstyle would not run as verify occurs after the test phase.
For example:
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.17</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>
- mvn Checkstyle使用
- mvn checkstyle/findbugs/pmd 插件使用
- mvn plugin checkstyle/findbugs/pmd在多module项目中的使用
- CHECKSTYLE使用
- checkstyle 使用
- mvn 使用
- MVN使用
- mvn 使用
- CheckStyle使用详解
- Struts:CheckStyle使用详解
- Checkstyle使用参考
- CheckStyle使用详解
- Checkstyle的 使用
- checkstyle安装和使用
- checkstyle安装及使用
- CheckStyle使用详细手册
- CheckStyle的使用
- Checkstyle使用参考
- 系统对话框
- LeetCode 203 Remove Linked List Elements
- PHP + Lighttpd for Android
- AnimationCurve
- PHP and Lighttpd for Android
- mvn Checkstyle使用
- Eclipse使用技巧 - 1. 自动添加getter和setter
- Porting PHP to Android——没有具体移植过程
- 零字节WSASend,WSARecv
- POJ 2948 DP
- php-5.5.1-android.patch.v3
- iOS学习笔记08--Objective-C反射
- java正则表达式(二)
- 关于tornado的国际化遇到的问题记录