Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven specific version of a snapshot dependency

Tags:

maven-2

People also ask

What is a snapshot version in Maven?

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.

What is the difference between snapshot and version?

The difference between a "real" version and a snapshot version is that snapshots might get updates. That means that downloading 1.0-SNAPSHOT today might give a different file than downloading it yesterday or tomorrow.

What means snapshot version?

What is SNAPSHOT? SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build.

What is a snapshot version artifact?

Snapshot artifacts are artifacts generated during the development of a software project. A Snapshot artifact has both a version number such as “1.3. 0” or “1.3” and a timestamp in its name. For example, a snapshot artifact for commons-lang 1.3. 0 might have the name commons-lang-1.3.


To use a specific snapshot version of a dependency, the referenced artifact should be installed/deployed with a unique snapshot version number. See the uniqueVersion element in the POM reference/Repository. In this case you can reference it like:

...
<dependency>
<groupId>groupid</groupId>
<artifactId>artifact-id</artifactId>
<version>1.0.0-20090610.041042-5</version>
</dependency>
...

Maven repository manager servers may have additional related features, like overriding the pom.xml's uniqueVersion setting. For example see the Artifactory User Guide about this feature (additionally, you can read here some arguments against using unique snapshot version numbers).


Yes, you can. Any version that is in your maven repositories can be used. I've ran into some problems where the trasnsitive dependencies mucked with the version though. That's where mvn dependency:tree came in handy.

  • Maven dependency mechanism
  • mvn dependency:tree

Use the Versions Maven plugin

http://mojohaus.org/versions-maven-plugin/examples/lock-snapshots.html

and

http://mojohaus.org/versions-maven-plugin/examples/unlock-snapshots.html