How to define a checkstyle SuppressionFilter in both eclipse and sbt

时间:2015-10-29 16:00:56

标签: java eclipse sbt checkstyle

I would like to use the same checkstyle config in sbt (https://github.com/etsy/sbt-checkstyle-plugin) and in eclipse (http://eclipse-cs.sf.net/)

This works apart from the SuppressionFilter I can define the file either so that it works in eclipse:

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

Then sbt complains

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

Or so that it works in sbt:

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

Then eclipse complains with

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

I found this solution for ant: How to define suppressions-definitions for checkstyle, that work with both ant and eclipse

But I am new to sbt, and have no idea how I define a variable in build.sbt in such a way, that it will be picked up by the checkstyle plugin.

What could I do? I would like to configure as little as possible in eclipse, as that would have to be done on each developer machine.

thanks

1 个答案:

答案 0 :(得分:0)

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

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