Best practices for Maven version control

What is the best way to change the version of the Maven project to release this version and then return to the *-SNAPSHOT .

I am currently doing the following:

  • extract current version (most likely using SNAPSHOT ) from pom.xml
  • increment version ( mvn -DnewVersion=<something> versions:set ), following the rules described in the question Maven artifact version for patches
  • mvn:install to send to repo
  • renaming the version with the addition of SNAPSHOT postfix.
  • making changes (using some version control system)

I have a strong feeling that I am doing something wrong and / or inefficient.

+48
maven versioning
Mar 04 2018-12-12T00:
source share
2 answers

You can use the maven-release-plugin to release your artifacts. Then automatically all of your versions will be incremented using the release plugin. An exception may be if you go from 1.0.3-SNAPSHOT to 1.1.0-SNAPSHOT. Development timeline with Maven:

 1.0.0-SNAPSHOT 1.0.0 1.0.1-SNAPSHOT 1.0.1 1.0.2-SNAPSHOT 1.0.2 .. 

To go from SNAPSHOT to the release version, you must use the maven release plugin, you can release the artifact simply by using:

First step:

 mvn release:prepare 

Last step:

 mvn release:perform 

If you want to accept the defaults, you can simply add -B as:

 mvn -B release:prepare 

or you can combine these steps into one:

 mvn -B release:prepare release:perform 

The above can also be used from solution CI.

Using mvn install is only for installing artifacts into your local repository. If you work with a real one, as a storage manager (which I can recommend), you should use:

 mvn deploy 

One of the requirements for using the release plugin is to configure the scm area in your pom (hope you use a version control?).

+61
Mar 04 '12 at 12:12
source share

If you want more control over the release phase, the maven-release plugin (mrp) will not help you.

In this case, I have modified versions-maven-plugin to be able to increase the version, as well as add / remove the SNAPSHOT suffix .

Thanks to these new features, you can write a script that does the same thing as mrp, but you have full control over every step.

For example, mrp commits a modified version before it tries to create it. If the assembly failed, you must return this message or, in the case of SVN, you need to issue another return-commit.

Note. I am not the original author of the increment function. I took it from autoincrement-versions-maven-plugin as indicated on the github page.

+4
Jan 28 '15 at 14:56
source share



All Articles