利用shell自动化打包java工程

#!/bin/bash

#wuzhong@taobao.com
#打包工程用

usage()
{
	echo 'build.sh -s(svn up) -x(antx.properties) -m(mvn clean package) -a(do all) kjava/wtm ]'
	exit 1
}

#usage

NEED_MVN=1
while getopts "sxma:" options;do
	case $options in
		s) echo "svn up"
		   HAS_OPT=1
           NEED_SVN=1;;
		x) echo "copy antx properties"
		   HAS_OPT=1
           NEED_ANTX=1;;
		m) echo "mvn clean package"
		   HAS_OPT=1
		   NEED_MVN=1;;
        a) echo "do all: svn up , antx properties , mvn clean package"
           HAS_OPT=1
           NEED_MVN=1
           NEED_SVN=1
           NEED_ANTX=1;;		
		*) usage;;
	esac
done

#APP_NAME=wtm
APP_PATH=/home/wuzhong/workspace/
#获取最后一个参数
RELATIVE_PATH=${!#}
APP_NAME=$(basename $RELATIVE_PATH)

#对参数做判断
#if [ $HA ]

APP_PATH=${APP_PATH}${RELATIVE_PATH}

echo "app path is : $APP_PATH ; app name is $APP_NAME "

[ $NEED_ANTX ] && if [ -f /home/wuzhong/work/${APP_NAME}_antx.properties ]
    then
	echo "copy antx properties from " /home/wuzhong/work/${APP_NAME}_antx.properties
        cp /home/wuzhong/work/${APP_NAME}_antx.properties /home/wuzhong/antx.properties
    else
    	echo "===============antx.properties is not exist=============="
        exit 0
    fi

if [ ! -d $APP_PATH ]
then 
	echo "==============project doesnot exit==========" ; 
	exit 0
fi

if [ $NEED_SVN ] 
then
	cd $APP_PATH
	svn up
fi

if [ $NEED_MVN ]
then
	cd $APP_PATH
	mvn clean package 
fi
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值