2018-08-31 11:49:48 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2018-09-17 16:27:41 +08:00
|
|
|
get_local_maven_project_version()
|
|
|
|
{
|
2020-09-02 15:35:46 +08:00
|
|
|
"$DIR/mvnw" -T 2C -Dmaven.test.skip=true -DskipTests=true -Dmaven.javadoc.skip=true org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate \
|
2018-11-08 17:43:49 +08:00
|
|
|
-Dexpression=project.version -f $DIR/pom.xml -B | grep -e '^[^\[]' | cut -b 1-5
|
2018-09-17 16:27:41 +08:00
|
|
|
}
|
|
|
|
|
2018-11-08 19:46:48 +08:00
|
|
|
"$DIR/mvnw" -version
|
|
|
|
|
2018-09-17 16:27:41 +08:00
|
|
|
CUR_VERSION=$(get_local_maven_project_version)
|
2018-08-31 11:49:48 +08:00
|
|
|
|
|
|
|
# arthas's version
|
|
|
|
DATE=$(date '+%Y%m%d%H%M%S')
|
|
|
|
|
|
|
|
ARTHAS_VERSION="${CUR_VERSION}.${DATE}"
|
|
|
|
|
2018-10-18 16:51:57 +08:00
|
|
|
echo "${ARTHAS_VERSION}" > $DIR/core/src/main/resources/com/taobao/arthas/core/res/version
|
2018-08-31 11:49:48 +08:00
|
|
|
|
|
|
|
# define newset arthas lib home
|
|
|
|
NEWEST_ARTHAS_LIB_HOME=${HOME}/.arthas/lib/${ARTHAS_VERSION}/arthas
|
|
|
|
|
|
|
|
|
|
|
|
# exit shell with err_code
|
|
|
|
# $1 : err_code
|
|
|
|
# $2 : err_msg
|
|
|
|
exit_on_err()
|
|
|
|
{
|
|
|
|
[[ ! -z "${2}" ]] && echo "${2}" 1>&2
|
|
|
|
exit ${1}
|
|
|
|
}
|
|
|
|
|
2018-09-13 01:02:15 +08:00
|
|
|
# maven package the arthas
|
2020-09-02 15:35:46 +08:00
|
|
|
"$DIR/mvnw" clean package -T 2C -Dmaven.test.skip=true -DskipTests=true -Dmaven.javadoc.skip=true -f $DIR/pom.xml \
|
2018-08-31 11:49:48 +08:00
|
|
|
|| exit_on_err 1 "package arthas failed."
|
|
|
|
|
2018-10-18 16:51:57 +08:00
|
|
|
rm -r "$DIR/core/src/main/resources/com/taobao/arthas/core/res/version"
|
|
|
|
|
2020-06-22 21:51:55 +08:00
|
|
|
packaging_bin_path=$(ls "${DIR}"/packaging/target/arthas-bin.zip)
|
2018-08-31 11:49:48 +08:00
|
|
|
|
|
|
|
# install to local
|
2018-10-18 16:51:57 +08:00
|
|
|
mkdir -p "${NEWEST_ARTHAS_LIB_HOME}"
|
2018-09-27 16:56:46 +08:00
|
|
|
unzip ${packaging_bin_path} -d "${NEWEST_ARTHAS_LIB_HOME}/"
|
2018-09-07 01:28:40 +08:00
|
|
|
|
2018-09-07 01:45:26 +08:00
|
|
|
# print ~/.arthas directory size
|
|
|
|
arthas_dir_size="$(du -hs ${HOME}/.arthas | cut -f1)"
|
|
|
|
echo "${HOME}/.arthas size: ${arthas_dir_size}"
|