I have a company-wide parent pom with a <dependencyManagement>
section which defines the versions of my projects that should be used throughout my application, some of which are SNAPSHOTs, a bit like this:
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>my.group</groupId>
<artifactId>myArtifact</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
...
<dependencies>
</dependencyManagement>
When I run release:prepare
on the parent pom, these SNAPSHOTs are not removed. The result is that the projects which inherit from the parent cannot use its versions when being released themselves. How do I ensure that the <dependencyManagement>
section of the parent pom is updated when I release?
I saw this question: why does maven release plugin allow for SNAPSHOT version in dependency managment?, but the tickets mentioned claim to be fixed in earlier versions of the plugin.
Maven Release Plugin 2.3.1
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Java version: 1.6.0_31, vendor: Sun Microsystems Inc.
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Release repositories hold releases and Snapshot repositories hold snapshots. In maven a snapshot is defined as an artifact with a version ending in -SNAPSHOT. When deployed, the snapshot is turned into a timestamp. By definition, snapshots are mutable, releases are immutable.
Instead, mvn release:perform creates a new snapshot version and uploads that snapshot jar to the releases repository.
Snapshot simply means depending on your configuration Maven will check latest changes on a special dependency. Snapshot is unstable because it is under development but if on a special project needs to has a latest changes you must configure your dependency version to snapshot version.
A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.
The maven-release-plugin
is only concerned with checking whether you have SNAPSHOT
-s in your <dependencies/>
section. The <dependencies/>
will be inherited by all modules which extend this parent. They will always try to resolve these dependencies before building.
The difference between the <dependencies/>
and <dependencyManagement/>
sections is that the latter only defines versions which will be used. This said, the release plugin is not at all concerned if you have defined SNAPSHOT
-s there, unless this parent project is an aggregator or part of an aggregator and this parent is being released as a whole with the aggregator.
Similarly, the maven-release-plugin does not take care of <pluginManagement/>
. Also, I believe it only addresses Maven properties containing artifact versions only when these are relating to <dependencies/>
.
The worse part is -- as far as I recall -- you will not even get warned if a dependency/plugin has a SNAPSHOT
version, if it's in a <*Management/>
section.
For this reason, the approach I have resorted to is to have a parent POM with <properties/>
containing the versions of the artifacts. Before releasing it, I scan it for SNAPSHOT
-s using grep:
grep SNAPSHOT pom.xml
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