Created
November 23, 2016 13:28
-
-
Save adriangl/689efa25cc6024f08517c40cbf83e260 to your computer and use it in GitHub Desktop.
Git pre-commit script for running Checkstyle in all Android-Studio based project files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Define paths where the checkstyle file is and where to check for style inconsistencies | |
CHECKSTYLE_PATH="checkstyle.xml" | |
CHECKSTYLE_FOLDERS_TO_CHECK="app/src/main/java app/src/androidTest/java app/src/test/java" | |
#Check if the 'checkstyle' command is installed | |
#Magic: http://stackoverflow.com/a/677212 | |
command -v checkstyle >/dev/null 2>&1 || { echo >&2 "checkstyle is not installed, aborting.\nInstall it using brew or apt-get"; exit 1; } | |
#Run checkstyle over our files | |
checkstyle -c $CHECKSTYLE_PATH $CHECKSTYLE_FOLDERS_TO_CHECK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment