forked from jbosstm/narayana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·234 lines (199 loc) · 6.05 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/sh
### ====================================================================== ###
## ##
## This is the main entry point for the build system. ##
## ##
## Users should execute this file rather than 'mvn' to ensure ##
## the correct version is being used with the correct configuration. ##
## ##
### ====================================================================== ###
# $Id: build.sh 105735 2010-06-04 19:45:13Z pgier $
# Create the bpa if you can
BPA=
uname | grep Linux >> /dev/null
if [ "$?" -ne "1" ]; then
uname -a | grep x86_64 >> /dev/null
if [ "$?" -ne "1" ]; then
BPA="-Dbpa=centos54x64"
else
BPA="-Dbpa=centos55x32"
fi
# This is required for the upgrade of g++ https://issues.jboss.org/browse/JBTM-1787
if [ -f /etc/fedora-release ]
then
uname -a | grep x86_64 >> /dev/null
if [ "$?" -ne "1" ]; then
BPA="-Dbpa=fc18x64"
fi
fi
fi
ORIG_WORKING_DIR=`pwd`
PROGNAME=`basename $0`
DIRNAME=`dirname $0`
GREP="grep"
ROOT="/"
# Ignore user's MAVEN_HOME if it is set
M2_HOME=""
MAVEN_HOME=""
JAVA_VERSION=$(java -version 2>&1 | grep "\(java\|openjdk\) version" | cut -d\ -f3 | tr -d '"' | tr -d '[:space:]'| awk -F . '{if ($1==1) print $2; else print $1}')
if [ $JAVA_VERSION -eq "9" ]; then
MAVEN_OPTS="$MAVEN_OPTS --add-modules java.corba"
MAVEN_OPTS="$MAVEN_OPTS --add-modules java.xml.bind"
MAVEN_OPTS="$MAVEN_OPTS --add-modules java.xml.ws"
export MAVEN_OPTS
fi
if [ -z "$MAVEN_OPTS" ]
then
if [ $JAVA_VERSION -ge "9" ]; then
MAVEN_OPTS="$MAVEN_OPTS -Xms1303m -Xmx1303m"
else
MAVEN_OPTS="$MAVEN_OPTS -Xms1303m -Xmx1303m -XX:MaxPermSize=512m"
fi
export MAVEN_OPTS
fi
# Default search path for maven.
MAVEN_SEARCH_PATH="\
tools
tools/maven \
tools/apache/maven \
maven"
# Default arguments
MVN_OPTIONS="-B -s \"${DIRNAME}/tools/maven/conf/settings.xml\" $BPA"
# Use the maximum available, or set MAX_FD != -1 to use that
MAX_FD="maximum"
# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
case "`uname`" in
CYGWIN*)
cygwin=true
;;
Darwin*)
darwin=true
;;
esac
#
# Helper to complain.
#
die() {
echo "${PROGNAME}: $*"
exit 1
}
#
# Helper to complain.
#
warn() {
echo "${PROGNAME}: $*"
}
#
# Helper to source a file if it exists.
#
source_if_exists() {
for file in $*; do
if [ -f "$file" ]; then
. $file
fi
done
}
find_maven() {
search="$*"
for d in $search; do
MAVEN_HOME="`pwd`/$d"
MVN="$MAVEN_HOME/bin/mvn"
if [ -x "$MVN" ]; then
# Found.
echo $MAVEN_HOME
break
fi
done
}
#
# Main function.
#
main() {
# If there is a build config file, source it.
source_if_exists "$DIRNAME/build.conf" "$HOME/.build.conf"
# Increase the maximum file descriptors if we can.
if [ $cygwin = "false" ]; then
MVN_OPTIONS="$MVN_OPTIONS -Dorson.jar.location=`pwd`/ext/"
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ]; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
# Use system's max.
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ]; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
else
MVN_OPTIONS="$MVN_OPTIONS -Dorson.jar.location=`cygpath -w $(pwd)/ext/`"
fi
# Try the search path.
MAVEN_HOME=`find_maven $MAVEN_SEARCH_PATH`
# Try looking up to root.
if [ "x$MAVEN_HOME" = "x" ]; then
target="build"
_cwd=`pwd`
while [ "x$MAVEN_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
cd ..
cwd=`pwd`
MAVEN_HOME=`find_maven $MAVEN_SEARCH_PATH`
done
# Make sure we get back.
cd $_cwd
if [ "$cwd" != "$ROOT" ]; then
found="true"
fi
# Complain if we did not find anything.
if [ "$found" != "true" ]; then
die "Could not locate Maven; check \$MVN or \$MAVEN_HOME."
fi
fi
# Make sure we have one.
MVN=$MAVEN_HOME/bin/mvn
if [ ! -x "$MVN" ]; then
die "Maven file is not executable: $MVN"
fi
# Need to specify planet57/buildmagic protocol handler package.
MVN_OPTS="-Djava.protocol.handler.pkgs=org.jboss.net.protocol"
# Setup some build properties
MVN_OPTS="$MVN_OPTS -Dbuild.script=$0"
# Change to the directory where the script lives, so users are not forced
# to be in the same directory as build.xml.
cd $DIRNAME
MVN_GOAL="";
ADDIT_PARAMS="";
# For each parameter, check for testsuite directives.
for param in $@ ; do
case $param in
-*) ADDIT_PARAMS="$ADDIT_PARAMS $param";;
clean) MVN_GOAL="$MVN_GOAL$param ";;
test) MVN_GOAL="$MVN_GOAL$param ";;
install) MVN_GOAL="$MVN_GOAL$param ";;
deploy) MVN_GOAL="$MVN_GOAL$param ";;
site) MVN_GOAL="$MVN_GOAL$param ";;
*) ADDIT_PARAMS="$ADDIT_PARAMS $param";;
esac
done
# Default goal if none specified.
if [ -z "$MVN_GOAL" ]; then MVN_GOAL="install"; fi
# Export some stuff for maven.
export MVN MAVEN_HOME MVN_OPTS MVN_GOAL
echo "$MVN $MVN_OPTIONS $MVN_GOAL $ADDIT_PARAMS"
# workaround in case 'mvn -f' is not supported, for example WFLY Thorntail plugin (THORN-2049)
if [ "$PRESERVE_WORKING_DIR" = "true" ]; then cd "$ORIG_WORKING_DIR"; fi
# Execute in debug mode, or simply execute.
if [ "x$MVN_DEBUG" != "x" ]; then
/bin/sh -x $MVN $MVN_OPTIONS $MVN_GOAL $ADDIT_PARAMS
else
exec $MVN $MVN_OPTIONS $MVN_GOAL $ADDIT_PARAMS
fi
}
##
## Bootstrap
##
main "$@"