Nil*_*idt 7 maven-2 checkstyle
我在maven 2中使用checkstyle插件.我现在想要将配置文件从默认配置文件切换到a)在线文件,或b)本地文件.我尝试了以下两件事,两件都没有用.有什么建议?
A)本地文件,直接位于pom.xml旁边的项目文件夹中
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
B)存储在服务器上的远程文件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>http://stud.hs-heilbronn.de/~nischmid/development/checkstyle-config.xml</configLocation>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这两种情况都会导致如下错误:
[INFO] Checkstyle报告生成中发生错误.嵌入式错误:在checkstyle执行期间失败无法找到资源'file:checkstyle.xml'.
任何帮助,将不胜感激!
我configLocation在Jira中看到了与插件版本2.5 相关的几个问题(如MCHECKSTYLE-129或MCHECKSTYLE-131),a)和b)与版本2.4一起工作正常.
所以,除非你使用Maven 3,否则我建议现在回滚到2.4:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugins>
Run Code Online (Sandbox Code Playgroud)
要么
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>http://stud.hs-heilbronn.de/~nischmid/development/checkstyle-config.xml</configLocation>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
作为旁注,对于多模块构建,请查看多模块配置.
我一直在尝试使用Checkstyle插件的3.0.1版本,但发现configLocation没有任何效果.试过上面的方法,但仍然没有运气.
总而言之,上面的答案可能确实有效,但您可能需要设置属性checkstyle.config.location.
使用-X获得调试输出,我看到:
[DEBUG] (f) configLocation = config/sun_checks.xml
Run Code Online (Sandbox Code Playgroud)
在日志中进一步滚动,看起来好像configLocation没有设置:
<configLocation default-value="config/sun_checks.xml">${checkstyle.config.location}</configLocation>
Run Code Online (Sandbox Code Playgroud)
基于该消息,我在全局中设置属性<properties>如下:
<checkstyle.config.location>${basedir}/config/checkstyle-configuration.xml</checkstyle.config.location>
Run Code Online (Sandbox Code Playgroud)
这有效,但导致插件抛出异常.在一些谷歌搜索后,我将以下内容添加到checkstyle配置文件中:
<module name="Checker">
...
<module name="TreeWalker">
...
<property name="cacheFile" value=""/>
Run Code Online (Sandbox Code Playgroud)
为了完整起见,最后一步来自以下Jira,在2.8中标记为已解决.区别在于它似乎使用空值,避免了设置${cachefile}属性的需要:
http://jira.codehaus.org/browse/MCHECKSTYLE-159
| 归档时间: |
|
| 查看次数: |
10942 次 |
| 最近记录: |