How to resolve ${samedir} in a gradle build script?

I use Checkstyle for static code-analysis. I also use a Checkstyle-plugin for eclipse as well as the Checkstyle-plugin for Gradle.

The plugin for Eclipse allows to use the variable ${samedir} to refer to a suppress.xml-file that resides in the same folder als the checkstyle-configuration file (http://eclipse-cs.sourceforge.net/#!/properties). This is in particular helpful when using a remote checkstyle-configuration file (http://sourceforge.net/p/eclipse-cs/bugs/265/).

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

I’d really like to use the same checkstyle-configuration in Eclipse and Gradle. Unfortunately, the Gradle-plugin seems to be unable to resolve the variable ${samedir} by default.

Is there a way to use ${samedir} or do I have to use an absolute path to refer to a suppression-file?

See also: http://stackoverflow.com/questions/29602867/using-samedir-in-checkstyle-plugins-for-gradle-and-eclipse

Hey,

you can configure properties used in checkstyle configurations in your build script like this:

apply plugin:'checkstyle'
...
...
checkstyle {
    configProperties['samedir'] = project.projectDir
}
1 Like