Using ${samedir} in Checkstyle-plugins for Gradle and Eclipse

 ̄綄美尐妖づ 提交于 2019-12-11 12:16:52

问题


I use a SuppressionFilter in my checkstyle-configuration. The path to the file suppression.xml is given relative to the checkstyle-configuration, using ${samedir} (http://eclipse-cs.sourceforge.net/#!/properties). Reason: I configured eclipse to use a remote checkstyle-configuration:

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

The same checkstyle-configuration is used by my Gradle build-script. Unfortunately, the checkstyle-plugin for gradle seems to be unable to resolve the variable ${samedir}.

Is there a way to anyway use the same config-file for Eclipse and Gradle? I really don't want to maintain two files or use an absolute path in the Checkstyle-configuration.


回答1:


You can manually set the "samedir" variable in your Gradle build script using configProperties.

checkstyle {
    configFile = file("${rootDir}/build_dependencies/my_checks.xml")
    configProperties = [samedir: "${rootDir}/build_dependencies"]
}

Source: adapted from Maven version



来源:https://stackoverflow.com/questions/29602867/using-samedir-in-checkstyle-plugins-for-gradle-and-eclipse

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