detekt: Don't fail the gradle task if the baseline file doesn't exist
Related with #3024 (this one is probably a prerequisite)
Expected Behavior
If a baseline is configured in gradle but the file doesn’t exist the task should not fail
Current Behavior
It fails.
Context
This is how we have it configured:
@get:InputFile
@get:Optional
@get:PathSensitive(PathSensitivity.RELATIVE)
val baseline: RegularFileProperty = project.objects.fileProperty()
and it seems that @get:InputFile
forces the file to exist. And if it doesn’t exist it fails. I tried to fix it but I know little about gradle.
I created the test already if someone want to use it: https://github.com/detekt/detekt/tree/baseline-doesnt-exist
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (16 by maintainers)
But, if the content of the baseline changes we want to rerun the task because the output of detekt can change, right? I think that we should keep using
@get:InputFile
Nice! There are some workaround there that I’ll try. Thanks!!
The concern is gradle cacheability, if the baseline file content gets changed (even we shouldn’t, but sometimes it does), we should fail the up-to-date. Supporting this issue requires manually performing upToDate checks, which could be an overhead in the long run.
We could use the following workaround: