Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven versions release candidates and snapshot

My goal is to release a project which have a single dependency. I have a nexus repository where i deploy both snapshot and release versions.

The one dependency I have has

group:artifact:1.1.0-SNAPSHOT

and the following Release Candidate is released in my nexus repo

group:artifact:1.1.0-RC1

when asking to the versions plugin to resolve the dependencies, it claims that no new dependency is available. So he consider that

1.1.0-SNAPSHOT > 1.1.0-RC1

However, If in my project, i have version 1.0.0-SNAPSHOT, version 1.1.0-RC1 is resolved as the newest version.

What am I missing? (I looked into the plugin sources and we have the following snippet:

String otherQualifier = otherVersion.getQualifier();

if ( otherQualifier != null )
{
  if ( ( qualifier.length() > otherQualifier.length() )
      && qualifier.startsWith( otherQualifier ) )
  {
    // here, the longer one that otherwise match is considered older
    result = -1;
  }
  else if ( ( qualifier.length() < otherQualifier.length() )
      && otherQualifier.startsWith( qualifier ) )
  {
    // here, the longer one that otherwise match is considered older
    result = 1;
  }
  else
  {
    result = qualifier.compareTo( otherQualifier );
  }
}

which seems buggy to me. Any idea?

like image 484
mirlitone Avatar asked Mar 14 '13 17:03

mirlitone


People also ask

What is difference between snapshot and release version?

A "release" is the final build for a version which does not change. A "snapshot" is a build which can be replaced by another build which has the same name. It implies that the build could change at any time and is still under active development.

What is the difference between 1.0 snapshot snapshot version and 1.0 release release version?

If we download 1.0-SNAPSHOT today then we may get different set of files than the one we get on downloading it yesterday. SNAPSHOT version can keep getting changes in it since it is under development. But release version always gives exactly same set files with each download.

What are snapshot versions in Maven?

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. For example, the snapshot of version 1.1 is 1.1-SNAPSHOT .

What is Release Candidate in Maven?

Release Candidate is a Maven plugin that makes integrating Maven projects with Continuous Delivery pipelines a little bit easier :-) smartcodeltd.co.uk/release-candidate-maven-plugin.


1 Answers

Maven version numbers are comprised as follows:

<major version>.<minor version>.<incremental version>-<qualifier>

If all the version numbers are equal, the qualifier is compared alphabetically. "RC1" and "SNAPSHOT" and sorted no differently to "a" and "b". As a result, "SNAPSHOT" is considered newer because it is greater alphabetically. See this page as a reference.

Note that a.b.c-RC1-SNAPSHOT would be considered older than a.b.c-RC1.

I'm not sure what to suggest as a solution - this is just how Maven versioning works.

like image 51
Duncan Jones Avatar answered Sep 24 '22 05:09

Duncan Jones