forked from highsource/annox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·192 lines (178 loc) · 4.9 KB
/
build.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/bash
#
# build.sh: Display a menu of build actions for this POM project.
#
# See: https://github.com/patrodyne/hisrc-hyperjaxb/blob/master/etc/BUILD_TOOLS.md
#
# Reference: https://maven.apache.org/what-is-maven.html
# https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail
#
# Hint: When sub-projects are present, use ../build.sh, ../../build.sh, etc.
# from the sub-project to invoke this script.
#
BASEDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${BASEDIR}/build-CFG.sh
source ${BASEDIR}/build-INC.sh
export MAVEN_OPTS="${MAVEN_OPTS} ${JVM_SYS_PROPS}"
BUILDER="output mvn ${MAVEN_ARGS}"
FGTITLE="$(basename $(pwd))"
BGTITLE="$(date --rfc-3339=sec) $(pwd)"
menu_options()
{
clear
if [ "${FULL_MENU}" = true ]; then
ACTION=$(whiptail --default-item="${ACTION}" --title "${FGTITLE}" --backtitle "${BGTITLE}" --menu "Select Action ..." --cancel-button "Close" 20 78 14 \
"a)" "Validate POM(s) correctness and that information is available" \
"b)" "Compare the effective POM with current POM" \
"c)" "Display plugins that have newer version available" \
"d)" "Display dependencies that have newer version available" \
"e)" "Display the dependency tree" \
"f)" "Resolve plugins and report dependencies" \
"g)" "Analyze dependencies and report on: (un)used and/or (un)declared" \
"h)" "Download source and javadoc jars to the local repository" \
"i)" "Clean and install the shared libraries to the local repository" \
"j)" "Clean and package all modules: libraries, assemblies, tests, etc." \
"k)" "Unit test all modules" \
"l)" "Integration test default, assembly modules" \
"m)" "Generate a site for each project" \
"v)" "Vim into current directory" \
3>&2 2>&1 1>&3)
else
ACTION=$(whiptail --default-item="${ACTION}" --title "${FGTITLE}" --backtitle "${BGTITLE}" --menu "Select Action ..." --cancel-button "Close" 20 78 13 \
"a)" "Validate POM(s) correctness and that information is available" \
"i)" "Clean and install the shared libraries to the local repository" \
"j)" "Clean and package all modules: libraries, assemblies, tests, etc." \
"k)" "Unit test all modules" \
"l)" "Integration test default, assembly modules" \
"v)" "Vim into current directory" \
3>&2 2>&1 1>&3)
fi
}
menu_actions()
{
if [ $? -eq 0 ]; then
case "${ACTION}" in
"a)") ${BUILDER} validate ;;
"b)") comparepom ;;
"c)") ${BUILDER} versions:display-plugin-updates ;;
"d)") ${BUILDER} versions:display-dependency-updates ;;
"e)") ${BUILDER} dependency:tree ;;
"f)") ${BUILDER} dependency:resolve-plugins ;;
"g)") ${BUILDER} dependency:analyze ;;
"h)") ${BUILDER} dependency:sources; mvn dependency:resolve -Dclassifier=javadoc ;;
"i)") ${BUILDER} -DskipTests=true clean install ;;
"j)") ${BUILDER} -DskipTests=true -Pall clean package ;;
"k)") ${BUILDER} -DskipTests=false -Pall test ;;
"l)") ${BUILDER} -DskipTests=false -Passembly clean integration-test ;;
"m)") ${BUILDER} -DskipTests=false -Pall site ;;
"v)") vim . ;;
esac
read -p "Press any key to continue..." anykey
return 0
else
echo "Done"
return 1
fi
}
comparepom()
{
# Check for GUI diff command.
unset DIFFCMD
if [ -n "$DISPLAY" ]; then
if iscmd meld; then
DIFFCMD="meld"
elif iscmd gvimdiff; then
DIFFCMD="gvimdiff -f"
fi
fi
# Otherwise; check for TUI diff command.
if [ -z "$DIFFCMD" ]; then
if iscmd vimdiff; then
DIFFCMD="vimdiff"
elif iscmd sdiff; then
DIFFCMD="output sdiff -w 160 -W -t --tabsize 2"
elif iscmd diff; then
DIFFCMD="output diff -w -c"
fi
fi
# If diff command discovered then proceed.
if [ -n "$DIFFCMD" ]; then
TMPFILE="$(mktemp --tmpdir pom.XXXXXXXXXX)"
${BUILDER} -Doutput="${TMPFILE}" help:effective-pom
xmllint --xpath "/projects/*[1]" "${TMPFILE}" >"${TMPFILE}-P1" 2>/dev/null
if [ -s "${TMPFILE}-P1" ]; then
${DIFFCMD} "${TMPFILE}-P1" "pom.xml"
else
${DIFFCMD} "${TMPFILE}" "pom.xml"
fi
rm ${TMPFILE}*
else
echo "OOPS: Please configure a diff command."
fi
}
iscmd()
{
command -v $1 >/dev/null
}
confirmation()
{
if (whiptail --title "Confirmation" --yesno "$1" 7 60) then
return 0
else
return 1
fi
}
message()
{
whiptail --title "$1" --msgbox "$2" 7 60
}
information()
{
message "Information" "$1"
}
warning()
{
message "Warning" "$1"
}
error()
{
message "Error" "$1"
}
output()
{
if [ "${BUILD_LOG}" = true ]; then
if [ -n "$DISPLAY" ]; then
$@ 2>&1 | tee "build.log"
else
$@ 2>&1 | tee "build.log" | less
fi
else
if [ -n "$DISPLAY" ]; then
$@
else
$@ | less
fi
fi
}
required()
{
if ! iscmd whiptail; then
echo "Please install whiptail!"
exit 1
fi
for CMD in mvn vim xmllint
do
if ! iscmd "${CMD}"; then
error "Please install ${CMD}"
exit 1
fi
done
}
# Display options and execute actions until user closes the menu.
required
while [ $? -eq 0 ]
do
menu_options
menu_actions
done
# vi:set tabstop=4 hardtabs=4 shiftwidth=4: