-
Notifications
You must be signed in to change notification settings - Fork 2
/
nmvn
executable file
·52 lines (48 loc) · 1.64 KB
/
nmvn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
#
# USAGE: nmvn <parameters and goals>
#
# Invoke maven with the supplied parameters and goals.
#
# When the build is complete, send a message to notification centre indicating if the build was successful, and
# the directory in which it was run (in case there are multiple builds running concurrently). If you invoked this
# script from either Terminal or iTerm2, clicking the notification should take you back to it.
#
# By using the 'project' as the group, any subsequent build notifications will replace the earlier ones for
# the same project, reducing notification centre clutter.
#
# Send a Notification to Notification Centre
function notify {
PROJECT=${PWD##*/}
SUBTITLE="in $PROJECT"
if [ $1 ]; then
TITLE="Build Successful"
MESSAGE="Build succeeded in $PROJECT; click to return."
else
TITLE="Build Failed"
MESSAGE="Build failed in $PROJECT; click to return."
fi
activate_term_program
terminal-notifier -title "$TITLE" -subtitle "$SUBITLE" -message "$MESSAGE" -group $PROJECT $ACTIVATE
}
# Set the 'ACTIVATE' variable based on the terminal in which this is running
function activate_term_program {
if [ $TERM_PROGRAM = "Apple_Terminal" ]; then
ACTIVATE="-activate com.apple.Terminal"
elif [ $TERM_PROGRAM = "iTerm.app" ]; then
ACTIVATE="-activate com.googlecode.iterm2"
else
ACTIVATE=""
fi
}
# Print the header comment from this file, ducking the shebang line, and stopping a the first line that doesn't start with a hash
function print_header_comment {
awk '/^# / { print substr( $0, 3 ) }; $0 !~ /^#/ { exit }' $0
}
# Print Usage or Execute
if [ $# == 0 ]; then
print_header_comment
else
mvn $*
notify $?
fi