今天晚上照着bash文档写了个方便maven build的bash脚本,在此分享
m.sh
核心脚本,可以用在任何服务器上,调用方式:
m.sh -icpn <maven dir>
其中:
-i:install
-c:clean
-p:package
-n:-Dmaven.test.skip=true
#!/bin/bash
TEMP=`getopt -o npic -- "$@"`
M_ARG=""
eval set -- "$TEMP"
while true ; do
case "$1" in
-n)
M_ARG="$M_ARG -Dmaven.test.skip=true"
shift
;;
-p)
M_ARG="$M_ARG package"
shift
;;
-c)
M_ARG="$M_ARG clean"
shift
;;
-i)
M_ARG="$M_ARG install"
shift
;;
--)
shift
break
;;
esac
done
DIR="$1"
if [[ -z $DIR ]]
then echo "Usage: m.sh [-nipc] <dir>";exit 1;
fi
if [[ ! -d $DIR ]]
then echo "dir <$DIR> not exists";exit 1;
fi
pushd $DIR
mvn $M_ARG
popd
-- EOF --
除非注明(如“转载”、“[zz]”等),本博文章皆为原创内容,转载时请注明: 「转载自程序员的信仰©」
本文链接地址:牛刀小试:bash编程