【问题标题】:How to define a checkstyle SuppressionFilter in both eclipse and sbt如何在 eclipse 和 sbt 中定义一个 checkstyle SuppressionFilter
【发布时间】:2016-01-29 21:12:56
【问题描述】:

我想在 sbt (https://github.com/etsy/sbt-checkstyle-plugin) 和 eclipse (http://eclipse-cs.sf.net/) 中使用相同的 checkstyle 配置

这与 SuppressionFilter 不同 我可以定义文件以便它在 eclipse 中工作

<module name="SuppressionFilter">
    <property name="file" value="${samedir}/checkstyleExcludeFiles.xml"/>
</module>

然后sbt抱怨

org.xml.sax.SAXException: Property ${samedir} has not been set

或者让它在 sbt 中工作

<module name="SuppressionFilter">
    <property name="file" value="checkstyleExcludeFiles.xml"/>
</module>

然后eclipse抱怨

cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyleExcludeFiles.xml' in module SuppressionFilter

我为 ant 找到了这个解决方案: How to define suppressions-definitions for checkstyle, that work with both ant and eclipse

但我是 sbt 的新手,不知道如何在 build.sbt 中定义一个变量,这样它就会被 checkstyle 插件拾取。

我能做什么?我想在 Eclipse 中尽可能少地进行配置,因为这必须在每台开发人员机器上完成。

谢谢

【问题讨论】:

  • 现在我有两个 checkstyle 配置,一个用于 sbt,一个用于 eclipse。由于 checkstyle 配置很少更改,这还不错。只是坏..

标签: java eclipse sbt checkstyle


【解决方案1】:

查看sbt-checkstyle-plugin code,我不支持设置properties。作为一种解决方法,我建议如下:

<module name="SuppressionFilter">
    <property name="file" value="${samedir}/checkstyleExcludeFiles.xml"
              default="checkstyleExcludeFiles.xml"/>
</module>

【讨论】:

  • 不幸的是 sbt 抱怨。 org.xml.sax.SAXException: 属性 ${samedir} 尚未设置。
猜你喜欢
  • 2011-01-07
  • 1970-01-01
  • 1970-01-01
  • 2010-10-16
  • 2011-05-10
  • 2013-01-22
  • 2011-03-18
  • 2012-04-19
  • 2013-08-17
相关资源
最近更新 更多