Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 238 lines (194 sloc) 6.639 kb
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
1 #!/bin/bash
2 ### ====================================================================== ###
3 ## ##
4 ## This is the main entry point for the build system. ##
5 ## ##
6 ## Users should execute this file rather than 'mvn' to ensure ##
7 ## the correct version is being used with the correct configuration. ##
8 ## ##
9 ### ====================================================================== ###
10
11 # $Id: build.sh 105735 2010-06-04 19:45:13Z pgier $
12
13 PROGNAME=`basename $0`
14 DIRNAME=`dirname $0`
15 GREP="grep"
16 ROOT="/"
17
18 # Ignore user's MAVEN_HOME if it is set
19 M2_HOME=""
20 MAVEN_HOME=""
21
22 MAVEN_OPTS="$MAVEN_OPTS -Xmx512M"
23 export MAVEN_OPTS
24
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
25 # The default search path for Maven.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
26 MAVEN_SEARCH_PATH="\
27 tools
28 tools/maven \
29 tools/apache/maven \
30 maven"
31
abc8730 JBPAPP-8212 Make integration.sh accept , or -s ... . Using -s will over...
Ondrej Zizka authored
32 # The default arguments. `mvn -s ...` will override this.
33 MVN_ARGS=${MVN_ARGS:-"-s ../tools/maven/conf/settings.xml"};
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
34
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
35 # Use the maximum available, or set MAX_FD != -1 to use that.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
36 MAX_FD="maximum"
37
38 # OS specific support (must be 'true' or 'false').
39 cygwin=false;
40 darwin=false;
41 case "`uname`" in
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
42 CYGWIN*) cygwin=true;;
43 Darwin*) darwin=true;;
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
44 esac
45
863202c @OndraZizka Don't run smoke tests if -Dtest=... is specified.
OndraZizka authored
46
47
48
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
49 #
863202c @OndraZizka Don't run smoke tests if -Dtest=... is specified.
OndraZizka authored
50 # Integration testsuite support.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
51 #
52
53 #
54 CMD_LINE_PARAMS=
55 TESTS_SPECIFIED="N"
56 . testsuite/groupDefs.sh
57
58 #
59 # Helper to process command line for test directives
60 # - user-specified parameters (allTests, stress-tests, benchmark-tests) are translated into the appropriate
61 # maven build profiles and removed from the command line
62 # - smoke tests run with build
63 #
64 process_test_directives() {
65
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
66 MVN_GOALS="";
0256450 @OndraZizka Set default goal also in integration-tests.sh
OndraZizka authored
67
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
68 # For each parameter, check for testsuite directives.
69 for param in $@ ; do
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
70 case $param in
abc8730 JBPAPP-8212 Make integration.sh accept , or -s ... . Using -s will over...
Ondrej Zizka authored
71 ## -s .../settings.xml - don't use our own.
72 -s) MVN_ARGS=""; CMD_LINE_PARAMS="$CMD_LINE_PARAMS -s";;
ceccf17 @OndraZizka Rewrite integration-tests.sh to reflect new pom.xml
OndraZizka authored
73 ## -DallTests runs all tests except benchmark and stress.
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
74 -DallTests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS -DallTests -fae";;
ceccf17 @OndraZizka Rewrite integration-tests.sh to reflect new pom.xml
OndraZizka authored
75
76 -Dinteg-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $INTEGRATION_TESTS";;
77 -Dcluster-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $CLUSTER_TESTS";;
78 -Dsmoke-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $SMOKE_TESTS";;
79 -Dbasic-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $BASIC_TESTS";;
80 -Ddomain-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $DOMAIN_TESTS";;
81 -Dcompat-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $COMPAT_TESTS";;
82 -Dbenchmark-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $BENCHMARK_TESTS";;
83 -Dstress-tests) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $STRESS_TESTS";;
84 ## Don't run smoke tests if a single test is specified.
85 -Dtest=*) TESTS_SPECIFIED="Y"; CMD_LINE_PARAMS="$CMD_LINE_PARAMS $param";; # -DfailIfNoTests=false
86
87 ## Collect Maven goals.
0256450 @OndraZizka Set default goal also in integration-tests.sh
OndraZizka authored
88 clean) MVN_GOALS="$MVN_GOALS$param ";;
89 test) MVN_GOALS="$MVN_GOALS$param ";;
90 install) MVN_GOALS="$MVN_GOALS$param ";;
91 deploy) MVN_GOALS="$MVN_GOALS$param ";;
92 site) MVN_GOALS="$MVN_GOALS$param ";;
ceccf17 @OndraZizka Rewrite integration-tests.sh to reflect new pom.xml
OndraZizka authored
93 ## Pass through all other params.
94 *) CMD_LINE_PARAMS="$CMD_LINE_PARAMS $param";;
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
95 esac
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
96 done
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
97
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
98 # Default goal if none specified.
99 if [ -z "$MVN_GOALS" ]; then MVN_GOALS="install"; fi
100 CMD_LINE_PARAMS="$MVN_GOALS $CMD_LINE_PARAMS";
0256450 @OndraZizka Set default goal also in integration-tests.sh
OndraZizka authored
101
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
102 # If no tests specified, run smoke tests.
103 if [[ $TESTS_SPECIFIED == "N" ]]; then
104 CMD_LINE_PARAMS="$CMD_LINE_PARAMS $SMOKE_TESTS"
105 fi
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
106 }
107
108 #
109 # Helper to complain.
110 #
111 die() {
112 echo "${PROGNAME}: $*"
113 exit 1
114 }
115
116 #
117 # Helper to complain.
118 #
119 warn() {
120 echo "${PROGNAME}: $*"
121 }
122
123 #
124 # Helper to source a file if it exists.
125 #
126 maybe_source() {
127 for file in $*; do
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
128 if [ -f "$file" ]; then
129 . $file
130 fi
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
131 done
132 }
133
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
134 find_maven() {
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
135 search="$*"
136 for d in $search; do
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
137 MAVEN_HOME="`pwd`/$d"
138 MVN="$MAVEN_HOME/bin/mvn"
139 if [ -x "$MVN" ]; then
140 # found one
141 echo $MAVEN_HOME
142 break
143 fi
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
144 done
145 }
146
147 #
148 # Main function.
149 #
150 main() {
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
151 # If there is a build config file. then source it.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
152 maybe_source "$DIRNAME/build.conf" "$HOME/.build.conf"
153
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
154 # Increase the maximum file descriptors if we can.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
155 if [ $cygwin = "false" ]; then
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
156 MAX_FD_LIMIT=`ulimit -H -n`
157 if [ $? -eq 0 ]; then
158 if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
159 # Use the system max.
160 MAX_FD="$MAX_FD_LIMIT"
161 fi
162
163 ulimit -n $MAX_FD
164 if [ $? -ne 0 ]; then
165 warn "Could not set maximum file descriptor limit: $MAX_FD"
166 fi
167 else
168 warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
169 fi
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
170 fi
171
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
172 # Try the search path.
173 MAVEN_HOME=`find_maven $MAVEN_SEARCH_PATH`
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
174
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
175 # Try looking up to root.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
176 if [ "x$MAVEN_HOME" = "x" ]; then
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
177 target="build"
178 _cwd=`pwd`
179
180 while [ "x$MAVEN_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
181 cd ..
182 cwd=`pwd`
183 MAVEN_HOME=`search $MAVEN_SEARCH_PATH`
184 done
185
186 # Make sure we get back.
187 cd $_cwd
188
189 if [ "$cwd" != "$ROOT" ]; then
190 found="true"
191 fi
192
193 # Complain if we did not find anything.
194 if [ "$found" != "true" ]; then
195 die "Could not locate Maven; check \$MVN or \$MAVEN_HOME."
196 fi
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
197 fi
198
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
199 # Make sure we have one.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
200 MVN=$MAVEN_HOME/bin/mvn
201 if [ ! -x "$MVN" ]; then
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
202 die "Maven file is not executable: $MVN"
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
203 fi
204
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
205 # Change to the directory where the script lives
206 # so users are not forced to be in the same directory as build.xml.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
207 cd $DIRNAME/testsuite
208
209 MVN_GOAL=$@
210 if [ -z "$MVN_GOAL" ]; then
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
211 MVN_GOAL="install"
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
212 fi
213
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
214 # Process test directives before calling maven.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
215 process_test_directives $MVN_GOAL
216 MVN_GOAL=$CMD_LINE_PARAMS
217
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
218 # Export some stuff for maven.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
219 export MVN MAVEN_HOME MVN_OPTS MVN_GOAL
220
abc8730 JBPAPP-8212 Make integration.sh accept , or -s ... . Using -s will over...
Ondrej Zizka authored
221 echo "$MVN $MVN_ARGS $MVN_GOAL"
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
222
bffe499 @OndraZizka Added -fae to -DallTests in integration-tests.sh
OndraZizka authored
223 # Execute in debug mode, or simply execute.
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
224 if [ "x$MVN_DEBUG" != "x" ]; then
abc8730 JBPAPP-8212 Make integration.sh accept , or -s ... . Using -s will over...
Ondrej Zizka authored
225 /bin/sh -x $MVN $MVN_ARGS $MVN_GOAL
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
226 else
abc8730 JBPAPP-8212 Make integration.sh accept , or -s ... . Using -s will over...
Ondrej Zizka authored
227 exec $MVN $MVN_ARGS $MVN_GOAL
1ad802a @OndraZizka In the middle of moving
OndraZizka authored
228 fi
229
230 cd $DIRNAME
231 }
232
233 ##
234 ## Bootstrap
235 ##
236
237 main "$@"
Something went wrong with that request. Please try again.