KAFKA-15476: Resolves cache misses in checkstyle (#14344)

Resolves cache misses in checkstyle tasks due to absolute paths in configProperties.

Sets configDirectory extension property, which is made available by the checkstyle plugin as ${config_loc} in the checkstyle xml files, as shown in the Checkstyle Gradle docs. The absolute paths set in configProperties are then replaced by relative paths from configDirectory. Because the header and suppression config file names are static and only referenced once, these were removed from configProperties and the file names are given directly in checkstyle.xml

Reviewers: Divij Vaidya <diviv@amazon.com>
This commit is contained in:
Tyler Bertrand 2023-09-19 03:51:57 -05:00 committed by GitHub
parent 1c402297d6
commit eea1854479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -685,7 +685,7 @@ subprojects {
} }
checkstyle { checkstyle {
configFile = new File(rootDir, "checkstyle/checkstyle.xml") configDirectory = rootProject.layout.projectDirectory.dir("checkstyle")
configProperties = checkstyleConfigProperties("import-control.xml") configProperties = checkstyleConfigProperties("import-control.xml")
toolVersion = versions.checkstyle toolVersion = versions.checkstyle
} }
@ -789,9 +789,7 @@ def fineTuneEclipseClasspathFile(eclipse, project) {
} }
def checkstyleConfigProperties(configFileName) { def checkstyleConfigProperties(configFileName) {
[importControlFile: "$rootDir/checkstyle/$configFileName", [importControlFile: "$configFileName"]
suppressionsFile: "$rootDir/checkstyle/suppressions.xml",
headerFile: "$rootDir/checkstyle/java.header"]
} }
// Aggregates all jacoco results into the root project directory // Aggregates all jacoco results into the root project directory

View File

@ -25,7 +25,7 @@
<!-- header --> <!-- header -->
<module name="Header"> <module name="Header">
<property name="headerFile" value="${headerFile}" /> <property name="headerFile" value="${config_loc}/java.header" />
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">
@ -79,7 +79,7 @@
<!-- dependencies --> <!-- dependencies -->
<module name="ImportControl"> <module name="ImportControl">
<property name="file" value="${importControlFile}"/> <property name="file" value="${config_loc}/${importControlFile}"/>
</module> </module>
<!-- whitespace --> <!-- whitespace -->
@ -149,7 +149,7 @@
</module> </module>
<module name="SuppressionFilter"> <module name="SuppressionFilter">
<property name="file" value="${suppressionsFile}"/> <property name="file" value="${config_loc}/suppressions.xml"/>
</module> </module>
<!-- Allows the use of the @SuppressWarnings annotation in the code --> <!-- Allows the use of the @SuppressWarnings annotation in the code -->