Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install GJF hook using a gradle task, rather than a gradlew hack. #298

Merged
merged 3 commits into from Apr 5, 2019

Conversation

lazaroclapp
Copy link
Collaborator

Fixes #297

@lazaroclapp
Copy link
Collaborator Author

lazaroclapp commented Apr 5, 2019

No integration test for this either, but I tried:

rm .git/hooks/pre-commit
./gradlew build
less .git/hooks/pre-commit

And also:

rm .git/hooks/pre-commit
./gradlew :nullaway:build
less .git/hooks/pre-commit

Copy link
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lazaroclapp lazaroclapp merged commit 8f06f38 into master Apr 5, 2019
@lazaroclapp lazaroclapp deleted the lazaro_commit_hooks_from_gradle branch April 5, 2019 16:49
@@ -38,6 +38,7 @@ subprojects { project ->
errorproneJavac deps.build.errorProneJavac
}
project.tasks.withType(JavaCompile) {
dependsOn(installGitHooks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, does this task cache correctly? Or just cheap enough to run every time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I see here: https://docs.gradle.org/current/userguide/build_cache.html#sec:task_output_caching_details

Some tasks, like Copy or Jar, usually do not make sense to make cacheable because Gradle is only copying files from one location to another. It also doesn’t make sense to make tasks cacheable that do not produce outputs or have no task actions.

I wonder if there's a friendlier way to handle this, such as using the spotless gradle plugin

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be cached, but involves only copying a single 358 bytes file, so checking the cache would not be appreciably faster, I think :) (and makes sure the hook gets re-added if the user removes it somehow). Is there a problem with it I am not seeing?

@msridhar
Copy link
Collaborator

msridhar commented Apr 8, 2019

@ZacSweers is your concern around build times? Or is there some other problem with this approach?

@ZacSweers
Copy link
Contributor

ZacSweers commented Apr 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants