Skip to content

Commit

Permalink
Fix Checkstyle to rely on the absolute path
Browse files Browse the repository at this point in the history
It turns out that relative path in the property
`<property name="file" value="src/checkstyle/checkstyle-suppressions.xml"/>`
in some cases is resolved against a Gradle deamon dir as a root for configs

* Fix Checkstyle plugin config to use an absolute path in the project for
the `configDirectory`.
* Since `configDirectory` is exposed as a Checkstyle config variable,
we can use its `${config_loc}` placeholder to rely on the absolute path
in the project
  • Loading branch information
artembilan committed May 6, 2020
1 parent ed14bcf commit 0fe7424
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ subprojects { subproject ->
}

checkstyle {
configFile = file("${rootDir}/src/checkstyle/checkstyle.xml")
configDirectory.set(file("src/checkstyle"))
toolVersion = '8.24'
}

Expand Down
4 changes: 2 additions & 2 deletions src/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<module name="Checker">

<module name="SuppressionFilter">
<property name="file" value="src/checkstyle/checkstyle-suppressions.xml"/>
<property name="file" value="${config_loc}/checkstyle-suppressions.xml"/>
</module>

<!-- Root Checks -->
<module name="RegexpHeader">
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt"/>
<property name="headerFile" value="${config_loc}/checkstyle-header.txt"/>
<property name="fileExtensions" value="java"/>
</module>
<module name="NewlineAtEndOfFile">
Expand Down

0 comments on commit 0fe7424

Please sign in to comment.