forked from a-langer/eclipse-oomph-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
88 lines (79 loc) · 2.77 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
#!/bin/bash
if [[ ${debug:-false} == true ]]; then
set -o xtrace # activate bash debug
mvnDebug="-X"
fi
build_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
ts=$(date +"%Y%m%d_%H%M%S")
build_local=1
local_cache=
for i in "$@"; do
case $i in
-d|--diag)
build_local=0
diag=1
;;
--local-cache)
read -p "delete local cache? (y/n) " -n 1 -r; echo; [[ $REPLY =~ ^[Yy]$ ]] && rm -rf ${build_dir}/.local_m2_cache
local_cache=-Dmaven.repo.local=.local_m2_cache
;;
-*|--*)
echo "unknow option $i provided"
exit 1
;;
*)
;;
esac
done
mkdir _log >/dev/null 2>&1
log_file=_log/${ts}_build.log
echo -e "#\n# build - log file $log_file\n#\n" 2>&1 | tee -a $log_file
echo -e "#\n# sourcing environment from build\n#\n" 2>&1 | tee -a $log_file
. ~/.klibio/set-env.sh # must not use pipe `2>&1 | tee -a $log_file`, cause export env vars will not work
. ~/.klibio/set-java.sh 17 2>&1 | tee -a $log_file
# create a build_rev for products and repo archives
read -r file_rev < version.txt
semver_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$"
if [[ $file_rev =~ $semver_regex ]]; then
build_rev=${file_rev}.$(date +"%Y%m%d-%H%M%S")
vm_build_rev=-Dbuild-rev=${file_rev}
echo "using semantic version: $build_rev"
else
echo "error: version.txt is not containing valid version [major.minor.bugfix]: $build_rev"
exit 1
fi
# signing properties
echo -e "#\n# sourcing sign properties\n#\n" 2>&1 | tee -a $log_file
readPropertyFile ${build_dir}/certificate/sign.properties # must not use pipe `2>&1 | tee -a $log_file`, cause export env vars will not work
env | grep "sign_" 2>&1 | tee -a $log_file
if [[ $sign_skip -eq "true" ]]; then
keystore=-Dkeystore=${build_dir}/certificate/${sign_keystore}
read -r -d '' signVM << EOM
-Dsign_skip=$sign_skip \
-Dsign_alias=$sign_alias \
-Dsign_keypass=$sign_keypass \
-Dsign_keystore=$sign_keystore \
-Dsign_storepass=$sign_storepass
EOM
fi
echo -e "# end of signing properties\n" 2>&1 | tee -a $log_file
if [[ ${diag} -eq 1 ]]; then
echo -e "#\n# execute diagnose\n#\n" 2>&1 | tee -a $log_file
./mvnw \
${MAVEN_OPTS} \
${mvnDebug} \
${local_cache} \
help:effective-settings 2>&1 | tee -a $log_file
fi
if [[ ${build_local} -eq 1 ]]; then
echo -e "#\n# execute local build - log file $log_file\n#\n" 2>&1 | tee -a $log_file
set -e
./mvnw clean package \
${MAVEN_OPTS} \
${mvnDebug} \
${local_cache} \
${vm_build_rev} \
${keystore} \
${signVM} 2>&1 | tee -a $log_file
fi
echo execute build $build_rev completed - log file created $log_file 2>&1 | tee -a $log_file