在多项目需要打包安装时采用的打包脚本
#!/bin/bash
package_path=$(cd $(dirname $0); pwd)
# 打包
function package_cmd() {
mvn clean package install -Dmaven.test.skip=true -Dcheckstyle.skip=true
}
# 拷贝
function find_package() {
# 查找并拷贝文件
find ./ -iname *.tar.gz -type f | xargs -i cp {} ${package_path}
if [[ -d "$(pwd)" ]]; then
echo "清理目录..."
rm -rf $(pwd)
fi
echo "打包完成,文件路径:${package_path}"
cd ..
}
# 参数说明 1 = git_path 2 = branch
function package() {
git_path=$1
project_name=$(basename ${git_path##*/} .git)
if [[ -d "${package_path}/${project_name}" ]]; then
echo "目标路径 '${project_name}' 已经存在"
exit 1
fi
echo "开始打包..."
# git 拉取指定分支项目
git clone -b $2 ${git_path}
# assembly
cd ${package_path}/${project_name}
# 编译打包
package_cmd
if [[ $? -ne 0 ]];then
echo "编译出错"
exit 1
fi
find_package
}
# 要打包的git项目地址
rest_utils=https://github.com/confluentinc/rest-utils.git
rest_utils_branch=5.5.0-post
# 打包
package ${rest_utils} ${rest_utils_branch}