ktlint-gradle icon indicating copy to clipboard operation
ktlint-gradle copied to clipboard

Intermediate output bin files contain full paths

Open zielezin opened this issue 3 years ago • 5 comments

Task org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask uses intermediate bin files with errors and these files contain absolute file paths that are problematic.

Because of this the task input changes depending on where the project is checked out. This causes cache misses.

zielezin avatar Sep 10 '21 13:09 zielezin

Screen Shot 2021-09-10 at 4 39 36 PM

zielezin avatar Sep 10 '21 14:09 zielezin

The cause of this difference to the inputs on the GenerateReportsTask is that the KtLintCheck which uses the KtLintWorkAction is writing the fully qualified paths to the files in the KtLintClassesSerializer.

In addition to the cache miss, the consequence of this is that since the KtLintCheck task is relocateable, it can be consumed across workspaces by the GenerateReportsTask with an incorrect fully qualified path to the error.

runningcode avatar Sep 10 '21 14:09 runningcode

Are there any good ways to write a unit test for this bug? Suggestions welcome.

JLLeitschuh avatar Sep 15 '21 16:09 JLLeitschuh

A cache relocateability test would be the best way. Here is an example (although outdated): https://github.com/gradle/kotlin-relocation-test

Here is such a relocation test inside the Android Cache fix plugin: https://github.com/gradle/android-cache-fix-gradle-plugin/blob/master/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy

runningcode avatar Sep 16 '21 12:09 runningcode

I'm more than happy to review a PR that resolves this issue. I don't think that either @Tapchicoma nor I have time to tackle this at the moment.

JLLeitschuh avatar Oct 03 '21 10:10 JLLeitschuh