Newer
Older
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
#!/bin/bash
config_file="config.properties"
test_config_file="test.properties"
if [ ! -f "$config_file" ]; then
echo "$config_file doesn't exist!"
exit 1
fi
# Append to a command a list of environment variables defined into a file
function add_properties {
command=$1
properties_file=$2
while read line
do
if [[ ! -z "$line" ]] && [[ ! "$line" =~ ^\# ]]; then
command="$command -D$line"
fi
done <<< "$(cat ../$properties_file)"
echo $command
}
function build_core {
cd TASMAN-core
mvn -q clean install
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-core built"
cd ..
}
function test_core {
cd TASMAN-core
$(add_properties "mvn clean install -P test" $test_config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
cd ..
}
function build_web_glassfish {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
}
function build_web_tomcat {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install -P ServletContainer" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
}
function build_web_embedded {
build_core
# build webapp
cd TASMAN-webapp
$(add_properties "mvn -q clean install -P ServletContainer,Jetty" $config_file)
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
# build embedded
cd TASMAN-embedded
war_file_path=`dirname ${PWD}`/TASMAN-webapp/target/tasman-webapp-*.war
war_file_path=`ls $war_file_path`
mvn clean -q install -Dwar_file_path=$war_file_path
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-embedded built"
cd ..
}
function build_installer_package {
build_core
# build webapp
cd TASMAN-webapp
mvn -q clean install -P ServletContainer,Jetty
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-webapp built"
cd ..
# build embedded
cd TASMAN-embedded
mvn -q clean install
if [ "$?" -ne 0 ]; then
echo "[ERROR] Error in ${FUNCNAME[0]}"
exit 1
fi
echo "TASMAN-embedded built"
cd ..
# copy TASMAN files
cp TASMAN-webapp/target/tasman-webapp-*.war .
cp TASMAN-embedded/target/tasman-embedded.jar .
mv tasman-webapp-*.war tasman-webapp.war
# create tar for self-extracting installer
tar cfz tasman.tar.gz tasman-webapp.war tasman-embedded.jar
rm tasman-webapp.war
rm tasman-embedded.jar
cp install_template.sh install.sh
cat tasman.tar.gz >> install.sh
rm tasman.tar.gz
echo "TASMAN install.sh built"
}
function print_usage {
echo "USAGE:"
echo " $0 command"
echo " "
echo "COMMANDS:"
echo " core build only TASMAN core"
echo " test run tests (using test.properties file)"
echo " glassfish build GlassFish war package (using config.properties file)"
echo " tomcat build Tomcat war package (using config.properties file)"
echo " embedded build embedded package (using config.properties file)"
echo " installer build install script (produces install.sh as output)"
exit 0
}
if [ "$#" -ne 1 ]; then
print_usage
fi
case "$1" in
"core")
build_core
;;
"test")
if [ ! -f "$test_config_file" ]; then
echo "$test_config_file doesn't exist!"
exit 1
fi
test_core
;;
"glassfish")
build_web_glassfish
;;
"tomcat")
build_web_tomcat
;;
"embedded")
build_web_embedded
;;
"installer")
build_installer_package
;;
*)
print_usage
;;
esac