What is the best way to change version of Maven project, to release this version and then return back to *-SNAPSHOT
development.
Currently I'm doing following:
SNAPSHOT
) from pom.xml
mvn -DnewVersion=<something> versions:set
), respecting rules described in the question Maven artifact version for patches mvn:install
to sent to repoSNAPSHOT
postfix.I have a strong feeling I'm doing something wrong and/or inefficient.
Rule #3 Never release using the Time-Stamped snapshot The release plugin will still fail if you do this because it correctly understands you have SNAPSHOT dependencies. The plugin has a flag to allow bypass this check and people unfortunately use it far too often.
M1 means Milestone 1, it's a release name, like beta or alpha. RC means Release Candidate.
Each maven dependency defined in the pom must have a version either directly or indirectly for example, through dependencyManagement or parent. That being said, if the version is not given, then the version provided in the dependencyManagement or the parent pom will be used.
Maven won't allow any other either. Build will fail if version is not found.
You should use the maven-release-plugin to release your artifacts. Than automatically all your versions will be incremented by the release-plugin. The exception might be if you are going from 1.0.3-SNAPSHOT to 1.1.0-SNAPSHOT . The timeline for developing with Maven is:
1.0.0-SNAPSHOT 1.0.0 1.0.1-SNAPSHOT 1.0.1 1.0.2-SNAPSHOT 1.0.2 ..
To go for the step from a SNAPSHOT to a release version you should use the maven release plugin you can release an artifact simply by using:
First step:
mvn release:prepare
The final step:
mvn release:perform
If you would like to accept the defaults you can simply add -B like:
mvn -B release:prepare
or you can combine those steps into a single one:
mvn -B release:prepare release:perform
The above can also be used from within a CI solution.
Using mvn install is only intended to install the artifacts into your local repository. If you are working with a real one like a repository manager (which i can recommend) you have to use:
mvn deploy
One requirement for using the release plugin is to configure the scm area in your pom (i hope you are using a version control?).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With