Created
November 1, 2013 15:05
-
-
Save josteinaj/7266810 to your computer and use it in GitHub Desktop.
Automatically build maven projects on file change.
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/bash | |
# Jostein Austvik Jacobsen © 2013 | |
# | |
# Before using: | |
# To increase your inotify watch limit, | |
# see: http://monodevelop.com/Inotify_watches_limit | |
# and for more info: http://askubuntu.com/questions/154255/how-can-i-tell-if-i-am-out-of-inotify-watches | |
# I have the limit set to 524288 as described in the last link and it works great. | |
# | |
# Usage: | |
# Go to the root directory of all the maven projects you want to monitor, then run this script. | |
# The script will automatically build the project that has changed, but not projects that depend on it. | |
function buildPom { | |
if [ "$1" = "" ]; then | |
echo "pom was not found" | |
return | |
fi | |
if [ -f "$1/pom.xml" ]; then | |
cd "$1" && mvn install | |
else | |
buildPom "`echo $1 | sed s/\\\\/[^/]*$//`" | |
fi | |
} | |
while true; do | |
change=$(inotifywait -e close_write,moved_to,create -r . --exclude target) | |
change=${change#./ * } | |
file=( $change ) | |
buildPom "$file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment