forked from byzer-org/byzer-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.sh
executable file
·134 lines (103 loc) · 3.25 KB
/
package.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
#!/usr/bin/env bash
function exit_with_usage {
cat << EOF
usage: package
run package command based on different spark version.
Inputs are specified with the following environment variables:
MLSQL_SPARK_VERSION - the spark version, 2.2/2.3/2.4 default 2.3
DRY_RUN true|false default false
DISTRIBUTION true|false default false
DATASOURCE_INCLUDED true|false default false
EOF
exit 1
}
set -e
set -o pipefail
if [[ $@ == *"help"* ]]; then
exit_with_usage
fi
SELF=$(cd $(dirname $0) && pwd)
cd $SELF
cd ..
MLSQL_SPARK_VERSION=${MLSQL_SPARK_VERSION:-2.3}
SCALA_VERSION=${SCALA_VERSION:-2.11}
DRY_RUN=${DRY_RUN:-false}
DISTRIBUTION=${DISTRIBUTION:-false}
OSS_ENABLE=${OSS_ENABLE:-false}
DATASOURCE_INCLUDED=${DATASOURCE_INCLUDED:-false}
COMMAND=${COMMAND:-package}
for env in MLSQL_SPARK_VERSION DRY_RUN DISTRIBUTION; do
if [[ -z "${!env}" ]]; then
echo "===$env must be set to run this script==="
echo "===Please run ./dev/package.sh help to get how to use.==="
exit 1
fi
done
# before we compile and package, correct the version in MLSQLVersion
#---------------------
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo ${machine}
current_version=$(cat pom.xml|grep -e '<version>.*</version>' | head -n 1 | tail -n 1 | cut -d'>' -f2 | cut -d '<' -f1)
MLSQL_VERSION_FILE="./streamingpro-mlsql/src/main/java/tech/mlsql/core/version/MLSQLVersion.scala"
if [[ "${machine}" == "Linux" ]]
then
sed -i "s/MLSQL_VERSION_PLACEHOLDER/${current_version}/" ${MLSQL_VERSION_FILE}
elif [[ "${machine}" == "Mac" ]]
then
sed -i '' "s/MLSQL_VERSION_PLACEHOLDER/${current_version}/" ${MLSQL_VERSION_FILE}
else
echo "Windows is not supported yet"
exit 0
fi
#---------------------
BASE_PROFILES="-Pscala-${SCALA_VERSION} -Ponline -Phive-thrift-server -Pcrawler"
if [[ "$MLSQL_SPARK_VERSION" > "2.2" ]]; then
BASE_PROFILES="$BASE_PROFILES -Pxgboost"
else
BASE_PROFILES="$BASE_PROFILES"
fi
BASE_PROFILES="$BASE_PROFILES -Pspark-$MLSQL_SPARK_VERSION.0 -Pstreamingpro-spark-$MLSQL_SPARK_VERSION.0-adaptor"
if [[ ${DISTRIBUTION} == "true" ]];then
BASE_PROFILES="$BASE_PROFILES -Passembly"
else
BASE_PROFILES="$BASE_PROFILES -pl streamingpro-mlsql -am"
fi
export MAVEN_OPTS="-Xmx6000m"
SKIPTEST=""
TESTPROFILE=""
if [[ "${COMMAND}" == "package" ]];then
BASE_PROFILES="$BASE_PROFILES -Pshade"
fi
if [[ "${COMMAND}" == "package" || "${COMMAND}" == "deploy" ]];then
SKIPTEST="-DskipTests"
fi
if [[ "${COMMAND}" == "test" ]];then
TESTPROFILE="-Punit-test"
fi
if [[ "${COMMAND}" == "deploy" ]];then
BASE_PROFILES="$BASE_PROFILES -Prelease-sign-artifacts"
BASE_PROFILES="$BASE_PROFILES -Pdisable-java8-doclint"
fi
if [[ "${OSS_ENABLE}" == "true" ]];then
BASE_PROFILES="$BASE_PROFILES -Poss-support"
fi
if [[ "$DATASOURCE_INCLUDED" == "true" ]];then
BASE_PROFILES="$BASE_PROFILES -Punit-test"
fi
if [[ ${DRY_RUN} == "true" ]];then
cat << EOF
mvn clean ${COMMAND} ${SKIPTEST} ${BASE_PROFILES} ${TESTPROFILE}
EOF
else
cat << EOF
mvn clean ${COMMAND} ${SKIPTEST} ${BASE_PROFILES} ${TESTPROFILE}
EOF
mvn clean ${COMMAND} ${SKIPTEST} ${BASE_PROFILES} ${TESTPROFILE}
fi