Fix remote cache misses for checkstyle tasks #45512
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a problem with cache misses for checkstyle tasks. As you can see from this build scan comparison, these two builds of the identical source tree differ in the
Checkstyle
taskconfigProperties
property, as well as a runtime API file input.https://gradle-enterprise.elastic.co/c/u4minwutaak3g/jabxgddp2tql6/task-inputs?expanded=WzI5Niw0MjksMTE2Ml0&task-text=checkstyleTest#j4kf4fqcsbb54
The issue here is the property replacement being done by checkstyle for the location of our suppressions config file. We use a token
${suppressions}
in ourcheckstyle.xml
file to be a stand in for the location of the suppression file to use. We then pass the real value to the task via theconfigProperties
task property. The issue here is that because the value given toconfigProperties
is an absolute path, this makes cache reusing across different workspaces impossible.To fix this we simply use the
configDir
task property instead, since we already copy these files into project-specific build directories. We can then use the standard${config_loc}
checkstyle property to resolve a relative path to an absolute one without the absolute path leaking into the Gradle task inputs.