aboutsummaryrefslogtreecommitdiff
path: root/mvnw.sh
blob: e759acfd78356be5f079c222be6be045aaab1284 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

print()
{
    echo [`date +"%Y-%m-%d %H:%M"`] "$1"
}

for arg in "$@"
do
    case $arg in
        compile)
            descr="Compilation"
            action=compile
            ;;
        test)
            descr="Testing"
            action="test"
            noTrim="-DtrimStackTrace=false"
            shift
            ;;
        -Dtest=*)
            #params="${arg#*=}"
            params="$arg"
            shift
            ;;
        -v)
            verbose=1
            ;;
    esac
done



T0=`date +"%s"`

print "Starting Maven $descr"
echo

IFS=''

if [ "$action" == "compile" ]; then
    OUTPUT=$(mvn compile \
                 | while read line; do echo $line|grep ERROR; done \
                 | grep -E "\[ERROR\] .*`pwd`" \
                 | sed 's/^\[ERROR\] //g' \
                 | sed 's/\[//g' \
                 | sed 's/,/:/g' \
                 | sed -E 's/\] (.*)$/ \[\1\]/g' \
                 | sort \
                 | uniq)
    if [ ! -z $verbose ]; then
        echo $OUTPUT
    else
        echo $OUTPUT | sed -E 's|\[.*\]||g'
    fi
    T1=`date +"%s"`
    TT=`expr $T1 - $T0`

    echo
    print "Maven $descr has endend. Time elapsed: $TT seconds"

    if [ ! -z "$OUTPUT" ]; then
        MSG="With errors."
    else
        MSG="Successful!"
    fi

    MSG=$MSG" Time elapsed: $TT seconds"

    notify-send "$descr completed" "$MSG"
else
    mvn $action $noTrim $params
fi