898   Java Shell

在Linux服务器发布Java项目时需要打包,一般是先svn update ,然后在 mvn clean install,写了shell脚本一键打包,代码如下:


#!/bin/bash

##
# function start
##

function svn_update
{
	# 代码目录
	local FUNC_CODE_DIR="/data/hgaop/test-rp/source/rp-v0.0.1-20150324-0"
	echo -e "\n"
	echo -e "START : svn update \n"
	echo -e "FUNC_CODE_DIR : ${FUNC_CODE_DIR} \n"
	
	cd ${FUNC_CODE_DIR}
	# 获取最新代码
	svn update 
		
	echo -e "\n"
	echo -e "END : svn update \n"

}


function package_code
{
	# 代码项目主目录
	local FUNC_WCS_DIR="/data/hgaop/test-rp/source/rp-v0.0.1-20150324-0/rp"
	# 打包配置文件
	local FUNC_PACKAGE_FILE="pom.xml"

	echo -e "\n"
	echo -e "START : package code \n"
	echo -e "FUNC_WCS_DIR : ${FUNC_WCS_DIR} \n"
	echo -e "FUNC_PACKAGE_FILE : ${FUNC_PACKAGE_FILE} \n"
	
	cd ${FUNC_WCS_DIR}

	# 打包
	mvn -T 1C -f ${FUNC_PACKAGE_FILE} clean install 
	
	
	echo -e "\n"
	echo -e "END : package code \n"
	
}



function run_main
{
	svn_update
	package_code
}

##
# function end
##


##
# main start
##

run_main


##
# main end
##




Leave a Reply

Your email address will not be published. Required fields are marked *