Interesting only for historical reasons.
Git can be used with many different workflows, see for instance https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow. Usually you work with a master branch and different feature branches.
The maven version is the branch name in git plus “-SNAPSHOT”. For example:
Advantages
Drawbacks
When we have a dependency to a SNAPSHOT version does usually mean that the dependency should be to the newest SNAPSHOT version, not to an older one. When we use the traditional maven version scheme, we have SNAPSHOT versions like 1.2.3-SNAPSHOT. After a release build, the number is changed (to e.g. 1.2.4-SNAPSHOT). Most of the time, the dependencies to SNAPSHOTs have to be updated (e.g from 1.2.3-SNAPSHOT to 1.2.4-SNAPSHT). This is errorprone work.
Setting the versions in multiple pom.xml
files by hand can be tedious.
Can set the version: https://www.mojohaus.org/versions-maven-plugin/
pom.xml
filesBut does not work with eclipse (https://bugs.eclipse.org/bugs/show_bug.cgi?id=530587)
If we have a single or multi module setup, the maven ci friendly versions https://maven.apache.org/maven-ci-friendly.html simplifies the setup. In this case, we have one property which defines the version, even in a multi module setup.
The pom.xml
parent pom:
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${revision}</version>
...
<properties>
<revision>some-SNAPSHOT</revision>
</properties>
and the pom.xml
of the child module references the parent pom like:
...
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>${revision}</version>
</parent>
...
When we have different versions or revision entries in the pom.xml, we have
-Drevision=xyz
command line optionVersion and revision properties do not change between branches. So no merge conflicts or unwanted overrrides
Advantages
revision
tag: local-SNAPSHOT${project.version}
${project.version}
pom.xml
of module M2 <m1.version>1.2.3</m1.version>
becomes <m1.version>${project.version}</m1.version>
Merge to master
pom.xml
in M2 changedpom.xml
changeshttp://maven.apache.org/maven-release/maven-release-plugin
Preparing a release goes through the following release phases:
- Check that there are no uncommitted changes in the sources
- Check that there are no SNAPSHOT dependencies
- Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
- Transform the SCM information in the POM to include the final destination of the tag
- Run the project tests against the modified POMs to confirm everything is in working order
- Commit the modified POMs
- Tag the code in the SCM with a version name (this will be prompted for)
- Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
- Commit the modified POMs
from http://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html
This has the following disadvantages
Advantages
Drawbacks