Git merge conflict only on version tag in pom.xml

Abidi picture Abidi · Aug 30, 2012 · Viewed 11.9k times · Source

Is there a way to avoid merge conflicts in version tag in pom.xml when merging master into a branch? I have quite a few pom files, 80, and all of them have same version which is different from one in master. It's laborious and time-consuming to execute git mergetool for 80 pom files just for a version tag.

Answer

emerino picture emerino · Oct 17, 2015

What I always do is change the version of the modules using the maven versions plugin, before merging from another branch (with a different version):

mvn versions:set -DnewVersion=1.1 -DgenerateBackupPoms=false

That'll change the version of all the current modules (parent and children) to the one you specify as the newVersion parameter. After changing the version, make a new commit (git commit...) and then do the merge. I've got all of this automated using a Jenkins task, but it shouldn't be difficult to implement it in other ways (e.g. sh script).