Do not mark entire root directory as input for git hook task #545
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.
In PR #526
projectDir
androotDirectory
were marked with@InputDirectory
annotation to fix problems with Gradle configuration cache. But those annotations actually mean thataddKtlintCheckGitPreCommitHook
task is using entire root directory content as its input. This does not make much sense. Not only that but in Gradle 7.x it causes annoying output whenaddKtlintCheckGitPreCommitHook
task is executed together with other tasks. In case of my project I have configuredbuild
task to depend onaddKtlintCheckGitPreCommitHook
(build.dependsOn addKtlintCheckGitPreCommitHook
) and now when I do./gradlew build
in Gradle 7.x (I'm testing on 7.2 to be exact) I get a lot of output like below:addKtlintCheckGitPreCommitHook
does not really depend on content of any of those directories so using@InputDirectory
annotation is a mistake. Instead@Input
annotation can be used with aString
property (that's what JavaDoc of@InputDirectory
annotation suggests for situations when directory content does not matter).But I went with a simpler solution making
projectDir
androotDir
regular private Kotlin property that Gradle does not see and track. I think intention of PR #526 wasn't to make those values configurable as task inputs so there's no need to mark them with@Input
annotation. There is also@Internal
annotation but I do not see any benefit of using it here over private property.I tested code with my project and no
Execution optimizations have been disabled
warnings were printed anymore.If you like/accept my Pull Request please add
hacktoberfest-accepted
label so it can be counted as my opensource contribution in Hacktoberfest contest.