Skip to content

Commit

Permalink
build: setup pre commit hook to check java format
Browse files Browse the repository at this point in the history
* updates gradle wrapper to latest version to enable ghooks to be used.
* enables ghooks plugin for gradle
* adds google java format pre commit hook
* adds test check file output to gitignore

resolves openequella#25
  • Loading branch information
ChristianMurphy committed Jun 10, 2020
1 parent 5962179 commit 811b162
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
# An example hook script to verify proper formatting.

files=$(git diff --cached --name-only --diff-filter=ACM | paste -s -d",")
# this only works if ignoreFailures is set to false (which it is by default)
./gradlew verifyGJF -DverifyGoogleJavaFormat.include="$files" &>/dev/null && exit 0

echo "Some files are not formatted properly. Please run:"
echo "./gradlew gJF -DgoogleJavaFormat.include=\"$files\""
exit 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ test*.properties
test*.xml
*.log
!src/test/**/*.log
test-check-files-output/
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.github.sherter.google-java-format' version '0.8'
id 'com.gtramontina.ghooks.gradle' version '1.1.0'
}

apply plugin: 'eclipse'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jul 12 11:19:13 CDT 2019
#Tue Jun 09 16:59:18 MST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

0 comments on commit 811b162

Please sign in to comment.