user1164061
user1164061

Reputation: 4342

maven - set the current project version

I use mvn versions:set -DnewVersion=x.x.x to change the current project version. It only changes the version under element "<version>". It does not change the version under element "<properties>" which has the dependent lib version. I am forced to do this manually every time.Is there anyway I can change all the versions in 1 step?

Upvotes: 0

Views: 862

Answers (1)

spieden
spieden

Reputation: 1269

I think I know what you're talking about. Are you trying to bump the version number in the relevant dependency blocks as well? I don't think there's a built-in way to do this, but here's an xmlstar one-liner that does for e.g. an entire groupId:

xmlstarlet ed -P -L -N p='http://maven.apache.org/POM/4.0.0' -u "/p:project/p:dependencies/p:dependency[p:groupId = 'my.group']/p:version" -v $VERSION $POM_FILE

I use this in a loop to batch set versions for many dependencies across many POMs.

Upvotes: 2

Related Questions