It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What about version in pom.xml for feature branches?

Johannes Gest Dec 01, 2013

I'm new to git, feature branching etc... but I really like it ;)

Thats my example:

I have my develop branch with let's say "1.0-SNAPSHOT" set as version in my pom.xml.

On top of that I create a feature branch and I want to be able to build that feature branch independently. As a result I (guess I) have to change the version to "1.0-<feature>-SNAPSHOT".

Everything works as expected now. Bamboo will build my feature branch, I can deploy the resulting artefacts, they are different, don't interfere, ...

But now I'm done with my feature and want to merge it.

When I create a "Pull Request" in Stash I have the pom.xml changes as well in there, although I don't want them to be there...

(of course I could just change the version back before the merge, but that's kinda weird)

=> So what is the common workflow for that?

4 answers

1 accepted

2 votes
Answer accepted
Charles O'Farrell Dec 02, 2013

Hi Johannes,

This is one of the real problems with maven. Checking the version into a file in Git is a bad idea (we have the same problem in Stash though).

What we do is to have a special build that does a maven release on a temporary branch, merges back to the original branch and _then_ does a 'git merge --strategy=ours' to the next 'upstream' branch. This merge will completely ignore the changes on the source branch (which is normally something you don't want to do). From that point you can merge up the chain as normal as there will be nothing to merge. It's not quite the same thing as what you're doing though, we don't bother with feature versions, only releases.

So basically you can't really merge the pull request without doing something manual first. Reverting the version before (or just after) the merge might be your best option. It's ugly, but that's maven for you.

Cheers,

Charles

Johannes Gest Dec 02, 2013

Thanks!

I worried about that, but good to hear that you have them same problem ;)

Chris Feldhacker Dec 02, 2013

We would love to see Stash enhanced to support this common scenario...!

1 vote
Xavier Arques Dec 02, 2013

Hi Johannes,

To avoid pom merge, you could perhaps use bamboo variables inside the pom as explained here.

If variable names are the same in feature branch and in develop branch no merge will be proposed for pom.xml

Cheers

Xavier

Johannes Gest Dec 02, 2013

I'll give it a try ;)

1 vote
Sven Oppermann Mar 10, 2015

Hi,

perhaps a little bit late, but if you still have this problem, have a look on my project on github. I solved that via a git merge driver. 

Greetings,
Sven

Zafar Hussaini Oct 14, 2016

This is ideal for our use. Thanks, Sven.

0 votes
qoomon Oct 15, 2017

https://github.com/qoomon/maven-branch-versioning-extension

This extension generate the version by the current branch. It will not change the pom.xml so.

Disclaimer: I am the author.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

943 views 12 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you