Maven 2 Checkstyle插件版本2.5-configLocation问题 [英] Maven 2 checkstyle plugin version 2.5 - Problem with configLocation

查看:409
本文介绍了Maven 2 Checkstyle插件版本2.5-configLocation问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在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:

[INFO]发生错误 Checkstyle报告生成.嵌入式的 错误:在检查样式期间失败 执行找不到资源 'file:checkstyle.xml'.

[INFO] An error has occurred in Checkstyle report generation. Embedded error: Failed during checkstyle execution Could not find resource 'file:checkstyle.xml'.

任何帮助将不胜感激!

推荐答案

我已经在 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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆