问题
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