forked from atlasmap/atlasmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·162 lines (136 loc) · 3.85 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
#!/bin/bash
# Exit if any error occurs
set -e
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Save global script args
ARGS="$@"
# Display a help message.
function displayHelp() {
echo "This script helps you build the syndesis monorepo."
echo "The available options are:"
echo " --skip-tests Skips the test execution."
echo " --skip-image-builds Skips image builds."
echo " --with-image-streams Builds everything using image streams."
echo " --namespace N Specifies the namespace to use."
echo " --resume-from Resume build from module."
echo " --clean Cleans up the projects."
echo " --batch-mode Runs mvn in batch mode."
echo " --help Displays this help message."
}
#
# Checks if a flag is present in the arguments.
function hasflag() {
filter=$1
for var in "${@:2}"; do
if [ "$var" = "$filter" ]; then
echo 'true'
break;
fi
done
}
#
# Read the value of an option.
function readopt() {
filter=$1
next=false
for var in "${@:2}"; do
if $next; then
echo $var
break;
fi
if [ "$var" = "$filter" ]; then
next=true
fi
done
}
# ======================================================
# Build functions
function modules_to_build() {
# app needs some love...
# modules="runtime camel ui app"
modules="runtime camel ui"
resume_from=$(readopt --resume-from $ARGS 2> /dev/null)
if [ "x${resume_from}" != x ]; then
modules=$(echo $modules | sed -e "s/^.*$resume_from/$resume_from/")
fi
echo $modules
}
function init_options() {
SKIP_TESTS=$(hasflag --skip-tests $ARGS 2> /dev/null)
SKIP_IMAGE_BUILDS=$(hasflag --skip-image-builds $ARGS 2> /dev/null)
CLEAN=$(hasflag --clean $ARGS 2> /dev/null)
WITH_IMAGE_STREAMS=$(hasflag --with-image-streams $ARGS 2> /dev/null)
NAMESPACE=$(readopt --namespace $ARGS 2> /dev/null)
HELP=$(hasflag --help $ARGS 2> /dev/null)
# Internal variable default values
OC_OPTS=""
MAVEN_OPTS=""
MAVEN_CLEAN_GOAL="clean"
MAVEN_IMAGE_BUILD_GOAL="fabric8:build"
MAVEN_CMD="${MAVEN_CMD:-${BASEDIR}/mvnw}"
# Apply options
if [ -n "$(hasflag --batch-mode $ARGS 2> /dev/null)" ]; then
MAVEN_OPTS="$MAVEN_OPTS --batch-mode"
fi
if [ -n "$SKIP_TESTS" ]; then
echo "Skipping tests ..."
MAVEN_OPTS="$MAVEN_OPTS -DskipTests"
fi
if [ -n "$SKIP_IMAGE_BUILDS" ]; then
echo "Skipping image builds ..."
MAVEN_IMAGE_BUILD_GOAL=""
fi
if [ -n "$NAMESPACE" ]; then
echo "Namespace: $NAMESPACE"
MAVEN_OPTS="$MAVEN_OPTS -Dfabric8.namespace=$NAMESPACE"
OC_OPTS=" -n $NAMESPACE"
fi
if [ -z "$CLEAN" ];then
MAVEN_CLEAN_GOAL=""
fi
if [ -n "$WITH_IMAGE_STREAMS" ]; then
echo "With image streams ..."
MAVEN_OPTS=" -Dfabric8.mode=openshift"
else
MAVEN_OPTS=" -Dfabric8.mode=kubernetes"
fi
}
function runtime() {
pushd runtime
"${MAVEN_CMD}" -Pjacoco,fabric8 $MAVEN_CLEAN_GOAL checkstyle:check install $MAVEN_OPTS
popd
}
function camel() {
pushd camel
"${MAVEN_CMD}" -Pjacoco $MAVEN_CLEAN_GOAL checkstyle:check install $MAVEN_OPTS
popd
}
function ui() {
pushd ui
yarn install --verbose --no-progress
yarn lint
yarn aot:build
if [ -z "$SKIP_TESTS" ]; then
./karma-xvfb.sh
fi
popd
}
function app() {
pushd app
yarn
popd
}
# ============================================================================
# Main loop
init_options
if [ -n "$HELP" ]; then
displayHelp
exit 0
fi
for module in $(modules_to_build)
do
echo "=========================================================="
echo "Building ${module} ...."
echo "=========================================================="
eval "${module}"
done