How to update version on dependent sibling module with Versions Maven Plugin

家住魔仙堡 提交于 2019-12-06 03:46:10

I ran into the same problem currently with the "use-releases" goal and was very happy that the versions plugin (just now?) supports this case by the parameter "excludeReactor=false"! :-)

Apparently one has to run the goal versions:use-latest-versions in the same path as where the pom.xml one needs to update is located. I solved this by moving the versions to the parent project and updating only that. I'm not too satisfied with this solution since it seems that the versions plugin does not support downgrading the version. Also, the new version is aquired from the (local) repository which means that the tool has to be built before updating the version. I think this was my problem initially.

Here's the script to solve this problem:

#!/bin/bash

if [[ $# -lt 1 ]]; then
    echo "Usage: $0 [version number]"
    exit 1
fi

function revert_version() {
    mvn -Pall versions:revert > /dev/null
    echo "ERROR: Failed updating the version"
    cat mvn_out.txt
    exit 1
}

v=$1
profile=cli
echo "Updating the version to $v..."
mvn -P$profile versions:set -DnewVersion=$v -DartifactId=tool -q
[ $? -eq 0 ] || revert_version

echo "Building the tool..."
mvn -P$profile install > /dev/null
[ $? -eq 0 ] || revert_version

echo "Updating the dependencies..."
mvn versions:use-latest-versions -Dincludes=com.somecompany:* -f parent/pom.xml -q
[ $? -eq 0 ] || revert_version
mvn -Pall versions:commit -q
[ $? -eq 0 ] || revert_version
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!