maven eclipse checkstyle 插件
我有自定义 checkstyle 检查文件(称为checks.xml),并且我尝试在 Maven 和 Eclipse 中使用相同的文件。除了 SuppressionFilter
之外,一切都运行良好。
在这个checks.xml文件中,
<module name="SuppressionFilter">
<property name="file" value="src/main/resources/checkstyle/checkstyle-suppressions.xml"/>
</module>
当我运行maven时,我可以使用This Works。但是,当我运行 Eclipse 时,我需要将配置更改为
<module name="SuppressionFilter">
<property name="file" value="${basedir}/src/main/resources/checkstyle/checkstyle-suppressions.xml"/>
</module>
如果我使用 maven 运行 ${basedir} 属性,则会收到属性 ${basedir} 尚未设置的错误。
有没有办法在 Maven 和 Eclipse 中使用相同的配置文件?我觉得应该有,但我只是缺少一些关于如何正确填充抑制过滤器的内容。
谢谢, 杰夫
I have custom checkstyle checks file (called checks.xml), and I'm trying to use that same file in both maven and eclipse. It all works well, except for the SuppressionFilter
.
In this checks.xml file, I have
<module name="SuppressionFilter">
<property name="file" value="src/main/resources/checkstyle/checkstyle-suppressions.xml"/>
</module>
This works when I run through maven. However, when I run through eclipse, I need to change the config to be
<module name="SuppressionFilter">
<property name="file" value="${basedir}/src/main/resources/checkstyle/checkstyle-suppressions.xml"/>
</module>
If I run with the ${basedir} property with maven though, I get the error that property ${basedir} has not been set.
Is there a way use this same configuration file in both maven and eclipse? I feel like there should be, but I'm just missing something on how to properly populate the suppression filter.
thanks,
Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就是地狱。 Eclipse 和 Maven 处理抑制的方式不同,并且不共享变量。
源自 Rolf Engelhard
所以在 pom.xml 中:
现在在 checkstyle.xml (${config_log}是 Eclipse 特定的东西,但是通过在 pom 中指定它,我们也可以将其提供给 maven):
如果您使用的是
maven-site-plugin
或任何其他也依赖于 CheckStyle 的插件不要忘记更新它们以拥有 config_loc 属性(或者将其声明为 pom 的全局属性,尽管我无法使其正常工作)。This is hell. Eclipse and Maven handle suppressions different and don't share variables.
Derived from Rolf Engelhard
So in pom.xml:
Now in checkstyle.xml (${config_log} is an Eclipse specific thing, but by specifying it in the pom we make it available to maven as well):
And if you're using
maven-site-plugin
or any other plugins that also rely on CheckStyle don't forget to update those to have the config_loc property as well (or declare it global to the pom, though I wasn't able to get this to work properly).当然,有一种方法可以在 Maven 和 Eclipse 中使用相同的配置文件,但首先需要进行一些设置。我写了一篇博客文章,介绍如何在多模块 Maven 项目中实现这一目标。请参阅: maven-checkstyle-and-eclipse
Sure there is a way to use the same configuration file in both maven and eclipse but it requires a little setup first. I wrote a blog post on how to achieve this even for a multi-module maven project. see: maven-checkstyle-and-eclipse
basedir=${session.executionRootDirectory}
对我有用,但仅当添加到
节点时,而不是 <代码><执行>!project.basedir
在多模块项目中效果不佳,因为它将指向子模块文件夹而不是根文件夹。<propertyExpansion>basedir=${session.executionRootDirectory}</propertyExpansion>
works for me, but only when added to the<plugin>
node, not to<execution>
!project.basedir
does not work well in multi-module projects, because it will point to the submodule folder instead of the root folder.您可以尝试将
${basedir}
定义为 pom 中的属性。请参阅pom 参考快速概述。
You could try defining
${basedir}
as a property in your pom.See the pom reference quick overview.