This repository was archived by the owner on Oct 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrun-eat.sh
executable file
·133 lines (105 loc) · 3.87 KB
/
run-eat.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
#!/bin/bash
set -eo pipefail
readonly JBOSS_VERSION_CODE=${1}
readonly SMODE=${2}
readonly NAME_PREFIX=${NAME_PREFIX:-'jboss-eap'}
readonly SETTINGS_XML=${SETTINGS_XML-"$(pwd)/settings.xml"}
readonly EAT_EXTRA_OPTS=${EAT_EXTRA_OPTS-''}
readonly MAVEN_CACHE_SERVER=${MAVEN_CACHE_SERVER:-$(hostname)}
set -u
usage() {
local script_name=$(basename ${0})
echo "${script_name} <jboss-version-code> <smode>"
echo
echo "Ex: ${script_name} wildfly"
echo
echo "On top of those arguments, this script excepts the following env vars to be set:"
echo '- MAVEN_HOME, set to the appropriate directory containing the Maven distribution'
echo ''
echo 'The following parameter can be overridden if needed:'
echo '- JBOSS_VERSION, set the version used for labelling jar dependencies associate to the AS version.'
echo '- NAME_PREFIX, default to 'jboss-eap' if not specified.'
echo '- MAVEN_LOCAL_REPOSITORY, path to a local mave repository to use for dependencies.'
echo '- SETTINGS_XML, path to custom settings.xml, default to ./settings.xml; Ignored if set to an empty value'
}
assertJBossASVersion() {
local pom_file_prefix=${1}
local m2_repo=${2}
cd "${m2_repo}"
local pom_file=$(find . -name "${pom_file_prefix}-parent*.pom")
if [ ! -e "${pom_file}" ]; then
echo "No pom file found with prefix ${pom_file_prefix} in ${m2_repo}."
echo "Cannot infer project version, please set JBOSS_VERSION env var."
exit 6
fi
which xpath 2>&1 > /dev/null
if [ "${?}" -ne 0 ]; then
echo 'Utility 'xpath' is missing from PATH. Please install tool or set JBOSS_VERSION.'
exit 7
fi
xpath "${pom_file}" '//project/version' 2> /dev/null | sed -e 's;</*version>;;g'
}
if [ -z "${JBOSS_VERSION_CODE}" ]; then
echo "Missing JBOSS_VERSION_CODE (eap7, eap64,...)."
usage
exit 1
fi
if [ -z "${MAVEN_HOME}" ]; then
echo "No MAVEN_HOME has been defined."
exit 2
fi
if [ ! -e "${MAVEN_HOME}" ]; then
echo "Provided MAVEN_HOME does not exist: ${MAVEN_HOME}"
exit 3
fi
if [ ! -d "${MAVEN_HOME}" ]; then
echo "Provided MAVEN_HOME is not a directory: ${MAVEN_HOME}"
exit 4
fi
#
# Set build configuratin (settings.xml, local maven repository) and
# Generating distribution specific value (JBOSS_VERSION and JBOSS_FOLDER)
#
if [ -e "${SETTINGS_XML}" ]; then
readonly SETTINGS_XML_OPTION="-s ${SETTINGS_XML}"
# see https://projects.engineering.redhat.com/browse/SET-126
sed -i "${SETTINGS_XML}" \
-e "s;MAVEN_CACHE_SERVER;${MAVEN_CACHE_SERVER};"
else
readonly SETTINGS_XML_OPTION=''
fi
readonly MAVEN_LOCAL_REPOSITORY=${MAVEN_LOCAL_REPOSITORY:-"$(pwd)/maven-local-repository"}
if [ -d "${MAVEN_LOCAL_REPOSITORY}" ]; then
readonly MAVEN_LOCAL_REPOSITORY_OPTION="-Dmaven.repo.local=${MAVEN_LOCAL_REPOSITORY}"
else
readonly MAVEN_LOCAL_REPOSITORY_OPTION=''
fi
readonly JBOSS_VERSION=${JBOSS_VERSION:-$(assertJBossASVersion "${NAME_PREFIX}" "${MAVEN_LOCAL_REPOSITORY}")}
export JBOSS_VERSION
readonly JBOSS_FOLDER=${JBOSS_FOLDER:-"$(pwd)/dist/target/${NAME_PREFIX}-${JBOSS_VERSION}"}
export JBOSS_FOLDER
if [ ! -d "${JBOSS_FOLDER}" ]; then
echo "The folder provided for JBoss AS server using the JBOSS_FOLDER env is not a directory: ${JBOSS_FOLDER}."
exit 5
fi
if [ ! -z "${SMODE}" ]; then
SMODE_CONFIG='-Dserver-integration'
else
SMODE_CONFIG='-Dstandalone'
fi
#
# Setting up maven
#
if [ -d "${MAVEN_HOME}/bin" ]; then
export MAVEN_HOME
export PATH="${MAVEN_HOME}/bin:${PATH}"
fi
export MAVEN_OPTS=${MAVEN_OPTS:-''}
export MAVEN_OPTS="${MAVEN_OPTS} -Dmaven.wagon.http.pool=false"
export MAVEN_OPTS="${MAVEN_OPTS} -Dmaven.wagon.httpconnectionManager.maxPerRoute=3"
export MAVEN_OPTS="${MAVEN_OPTS} -Xmx1024m -Xms512m -XX:MaxPermSize=256m"
#
# Run EAT
#
echo "Runing EAT on JBoss server: ${JBOSS_FOLDER} - using extra opts: ${EAT_EXTRA_OPTS}"
mvn clean install -D${JBOSS_VERSION_CODE} ${SMODE_CONFIG} ${SETTINGS_XML_OPTION} ${MAVEN_LOCAL_REPOSITORY_OPTION} ${EAT_EXTRA_OPTS}