Apache Maven / Release Plugin

Hey all --

Been using the Maven Release plugin to help me manage our ... releases.

Lately, however, I've been trying to build a beta version out of a non-master branch and am struggling managing version numbers.

Trying to "release" from this branch appears to be impossible due to the configuration of the Release plugin assuming/using the master branch.

Trying it once left me with my non-master branch "overwriting"/hiding my master branch ... I'm guessing because the plugin assumed I wanted the branch I was building to be saved as master ... and that's definitely not what I wanted.

Edit: my work-around is to simply tag the current branch head do my build, but all the version numbers in POMs remain the same as before.

What am I missing? Or, is there a better way to do this?
 

Apteris

Ars Tribunus Angusticlavius
9,590
Subscriptor
Trying to "release" from this branch appears to be impossible due to the configuration of the Release plugin assuming/using the master branch.
The maven-release-plugin will work on whichever branch you have previously checked out. It does not itself check out a branch. You can do this either yourself (e.g. with a shell command) or with the Maven SCM plugin.

Trying it once left me with my non-master branch "overwriting"/hiding my master branch
Don't really understand what you're saying here -- it might help if you posted the relevant section of your POM.

FWIW, I just ran release:prepare locally with a non-master branch, it performed the expected steps, including making local commits to the currently checked out branch.

Edit: my work-around is to simply tag the current branch head do my build, but all the version numbers in POMs remain the same as before.
That shouldn't be necessary as long as you correctly specify the tag to create during the release process.

What am I missing? Or, is there a better way to do this?
You may want to look into the release:stage goal. Start here.

[url=https://maven.apache.org/maven-release/maven-release-plugin/usage.html:3fhjsk2j said:
The Maven Release Plugin documentation[/url]":3fhjsk2j]Use a staging repository

Sometimes it is desirable to deploy a pre-release to be approved before made publicly available. One option is to create release candidates versions using the release:perform goal, but the final deployed artifact will NOT be the exact one that has been approved as RCx.

A common solution is to use a staging repository, where a test-version is deployed with it's documentation for review. If all is fine, it is then copied to the public repository. Using this strategy, the artifact that has been tested IS the one that is deployed.

The release:stage goal uses this strategy. It replaces the release:perform goal and does the same tasks, but requires a stagingRepository parameter. It will automatically re-configure the deploy and site-deploy goals to use the staging strategy.

After the release is complete, the release.properties and other release files will NOT be removed, so that you can still execute a release:rollback if some error has been detected and a new candidate must be created after some fixes. You just need to use a distinct tag in SCM, or rename the one that has been created if the SCM provider supports renaming tags.
 
I'll try to double check what I did back when it screwed up. I seem to remember that it overwrote (merged into?) master -- or at least overwrote the master's POMs (?) -- when it committed all the changes to the versions in the POMs.

I've been playing around with a fork to see if I can create a build using that fork instead (since I won't mess with the original repo.)

I may go back and futz around with that fork and try what you're talking about.
 

Apteris

Ars Tribunus Angusticlavius
9,590
Subscriptor
I seem to remember that it overwrote (merged into?) master -- or at least overwrote the master's POMs (?) -- when it committed all the changes to the versions in the POMs.
That's by design for the release:prepare goal. Assuming that you are on a snapshot version -- this is what it expects -- this goal will (among other things):

- update your POMs' version to whatever you want it to -- say, from 1.2.0-SNAPSHOT to 1.2.0.
- commit this
- tag the code in the SCM with a version name
- update the version again, to the next snapshot version -- say, 1.2.1-SNAPSHOT.

But as mentioned above, it should only do this on the current SCM branch.