Intellij checkstyle - setting path relative to the module

只愿长相守 提交于 2019-12-20 03:24:15

问题


My company is switching from Eclipse to IntelliJ. In Eclipse we had a following configuration for suppression filters in checkstyle.xml

<module name="SuppressionFilter">
    <property name="file" value="${checkstyle.config.dir}/suppressions.xml"/>
</module>
<module name="SuppressionFilter">
    <property name="file" value="${common.checkstyle.config.dir}/global-suppressions.xml"/>
</module>

Where:

  • common.checkstyle.config.dir was an absolute path to the common project(module in IntelliJ).

  • checkstyle.config.dir was an relative path to the project(module), and has a value of checkstyle.config.dir=${root.dir}/config/checkstyle

We would like to define a path for this file in IntelliJ, so it would look for the suppression filter in each MODULE/config/checkstyle directory(each module has a different suppression).

Does anyone know if it is possible? We have tried to find a solution for quite some time, but no luck so far.


回答1:


Thanks to Thomas Jensen's answer, I solved my very same problem. I answered in detail in this question. Hope it helps.




回答2:


The Checkstyle integration in Eclipse is more powerful in some respects than the one in IntelliJ. This is one such case, I believe.

I would recommend changing the Checkstyle setup so that you have only one Checkstyle configuration and a central suppressions file for all modules. As you will see, modules are more tightly related in IntelliJ than projects are in Eclipse, so this is actually a good idea.

In order to keep module-specific configuration and/or suppressions, you would have to do the following:

  1. Define all of the module-specific configurations in the central Checkstyle settings (so you have module1-rules, module2-rules etc. in your list).
  2. In each module, select the appropriate configuration from the drop-down box.

This is quite a lot of work though, so I think you will find centralizing the configuration more convenient. (By the way, here are the supported variables, none of which will help you, I'm afraid.)



来源:https://stackoverflow.com/questions/44944614/intellij-checkstyle-setting-path-relative-to-the-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!