maven 版本升级脚本

阅读更多
#!/usr/bin/env bash
if [ $# != 1 ]; then
	echo "usage: $0 ERROR!!! 至少需要一个参数,参数的范围:MAJOR|MINOR|REVISION"
	exit 1
fi

MVN_VERSION=$(mvn -q -N -Dexec.executable="echo"  -Dexec.args='${project.version}'  org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)

NEW_VERSION=$MVN_VERSION
if [ $1 == 'MAJOR' ]; then
	NEW_VERSION=`echo $MVN_VERSION | awk -F "." '{print $1+1".0.0-SNAPSHOT"}'`
elif [ $1 == 'MINOR' ]; then
    NEW_VERSION=`echo $MVN_VERSION | awk -F "." '{print $1"."$2+1".0-SNAPSHOT"}'`
elif [ $1 == 'REVISION' ]; then
    NEW_VERSION=`echo $MVN_VERSION | awk -F "." '{print $1"."$2"."$3+1"-SNAPSHOT"}'`
else
    echo "usage: $0 参数的范围:MAJOR|MINOR|REVISION"
    exit 1
fi

echo "project version $MVN_VERSION upgrade to $NEW_VERSION please enter:Yes(y)/No(n) ->"
read  input
if [[ $input == 'Y' || $input == 'y' ]]; then
    mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$NEW_VERSION
    exit 0
else
    exit 1
fi

你可能感兴趣的:(maven)