Skip to content

Instantly share code, notes, and snippets.

@dnault
Created July 14, 2016 19:17
Show Gist options
  • Save dnault/3996a29ae1281df903d9ae116ad2cbeb to your computer and use it in GitHub Desktop.
Save dnault/3996a29ae1281df903d9ae116ad2cbeb to your computer and use it in GitHub Desktop.
Wrapper script for Maven that sends a notification to the Mac OS X notification center when execution completes.
#!/bin/bash
#
# USAGE: gmvn <parameters and goals>
#
# Invoke maven with the supplied parameters and goals.
#
# When the build is complete, send a message to the notification center indicating if the build was successful, and
# the directory in which it was run (in case there are multiple builds running concurrently).
#
function notify {
local TITLE=$1
local MESSAGE=$2
osascript -e "display notification \"$MESSAGE\" with title \"$TITLE\""
}
PROJECT=${PWD##*/}
mvn $*
EXIT_STATUS=$?
if [ $EXIT_STATUS -eq 0 ]; then
notify "Success" $PROJECT
else
notify "FAILED" $PROJECT
fi
exit $EXIT_STATUS
@dnault
Copy link
Author

dnault commented Jul 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment