最近, 项目比较复杂, 改一个接口通常会同时发布好几个工程。 一个api升级, 每次都会cd 到不同目录下 svn up . 还有就是利用idea downloadsoruce download不下来
但 cd 到具体目录下 执行 mvn clean dependency:sources 却能down下源码, 解决频烦cd 的 执行svn XX 与 mvn 问题, 索性写了一个 sheel 脚本, 算是连连手罢了。
#!/bin/bash
#@coder jianjun.yu
#@date 2014年 07月 25日 星期五 21:06:43 HKT
function svnUp(){
if [ "$1" == ".svn" ]
then
echo "begin svn up"
svn up
echo "svn up end"
return 0;
fi
return 1;
}
function downSource(){
if [ $1 == "pom.xml" ]
then
echo "begin mvn clean dependency:sources "
mvn clean dependency:sources
echo "mvn clean dependency:sources"
return 0;
fi
return 1;
}
function switchFolderDealRegular(){
case $DEALFOLDER in
"svnup" )
svnUp $1
return $?
;;
u)
;;
esac
return 1;
}
function swtichFileDealRegular(){
case $DEALFILE in
"source" )
downSource $1
return $?
;;
esac
return 1;
}
function traversal(){
cd $1
local _tmpPath=`pwd`
for filename in `ls -a`
do
if [ x"$filename"x == x"."x ] || [ x"$filename"x == x".."x ]
then
continue;
fi
local result=0;
if [ -d $filename ]
then
switchFolderDealRegular ${filename}
if [ 255 -eq $? ]
then
break;
else
local willGoTo=${_tmpPath}/${filename}/
#echo "willGoto ${willGoTo}"
traversal $filename
#echo "willGoto ${_tmpPath}"
cd ${_tmpPath}
fi
else
swtichFileDealRegular ${filename}
if [ 255 -eq $? ]
then
break;
fi
fi
done
}
function checkParamer(){
echo '$@' =="$@"
DEALFOLDER=`echo $@ | sed 's/.*-f\([a-zA-Z]*\).*/\1/g'`
DEALFILE=`echo $@ | sed 's/.*-d\([a-zA-Z]*\).*/\1/g'`
TMP=$@
echo $DEALFOLDER
echo $DEALFILE
if [ "${DEALFOLDER}x" != "${TMP}x" ] || [ "${DEALFILE}x" != "${TMP}x" ]
then
return 0
else
return 1
fi
}
function usage(){
checkParamer $@
if [ $? -ne 0 ]
then
echo "must [-f svnup] || [-d [source] ] "
return
fi
_path=`pwd`
traversal ${_path}
echo "end"
}
usage $@