Gradle checkstyle importcontrol in multi-project build


(Thibault Kruse) #1

Hi,

I want to use the the gradle checkstyle plugin with a gradle multiproject setup. However when defining an import control file like this:

<module name="ImportControl">
   <property name="file" value="config/checkstyle/import-control.xml"/>
</module>

Then invoking gradle checkstyleMain looks for this file relative to where I invoke gradle, so in different locations when I invoke from the root project or a subproject. This is rather annoying. Is there a clean solution? It is a common problem. One solution would be a parameter to force checkstyle to be invoked always from the same folder (e.g. the root folder).

cheers,

Thibault


(Peter Niederwieser) #2

From what I remember, you can pass user-defined properties to the checkstyle task, which you can then reference from the checkstyle files.


(Thibault Kruse) #3

Indeed:

checkstyleMain {
    configProperties = ['baseDir': "$rootDir"]
...

It’s plain to see in the docs, but I missed it nevertheless.