问题描述
我正在maven 2中使用checkstyle插件.现在,我想将配置文件从默认文件切换为a)在线文件或b)本地文件.我尝试了以下两件事,但都没有起作用.有什么建议吗?
I am using checkstyle plugin in maven 2. I now want to switch my config file, from the default one to a) an online file, or b) a local file. I tried the following two things, which both didnt work. Any suggestions?
A)本地文件,直接在我的项目文件夹中pom.xml旁边
A) Local file, which is directly in my project folder next to the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
B)远程文件,存储在服务器上
B) Remote file, that is stored on a server
<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>
这两种情况都会导致如下错误:
Both cases result in an error like this:
任何帮助将不胜感激!
推荐答案
我已经在 Jira 以及2.5版的插件(例如 MCHECKSTYLE-129 或 MCHECKSTYLE-131 ),a)和b)都可以与版本2.4.
I've seen several issues related to configLocation
in Jira with the version 2.5 of the plugin (like MCHECKSTYLE-129 or MCHECKSTYLE-131), both a) and b) just work fine with the version 2.4.
因此,除非您使用的是Maven 3,否则我建议暂时回滚到2.4:
So, unless you're using Maven 3, I suggest to rollback to 2.4 for now:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.4</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugins>
或
<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>
请注意,对于多模块构建,请查看多模块配置.
As a side note, for a multi-modules build, have a look at the Multimodule Configuration.
这篇关于Maven 2 Checkstyle插件版本2.5-configLocation问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!