Neil
Neil

Reputation: 25815

How do you peg versions of Maven artifacts in the Nexus repository manager?

I'm building against various Lucene and Solr Maven artifacts from Apache's Maven repository hosted in the Nexus repository manager. The artifacts are version 4.0-SNAPSHOT and get updated daily, with older artifacts being deleted regularly.

I was wondering how to peg the artifacts to a specific date, so whenever a Maven client would ask for solr-core 4.0-SNAPSHOT, it would get the same version even if there was a newer one upstream.

I would also like to know how to explicitly update to the latest 4.0-SNAPSHOT, but still keep all previous versions that were downloaded.

Specifically, the "Apache Snapshots" repository is the default one that comes setup when you install Nexus.

Upvotes: 6

Views: 1386

Answers (2)

Manfred Moser
Manfred Moser

Reputation: 29912

When a snapshot is deployed to a repository server each new deployment is actually deployed as a time stamped version with an iterator number appended. If you want to use a specific version you just use the timestamp version of the snapshot rather than -SNAPSHOT.

E.g. look at https://repository.apache.org/content/groups/snapshots/org/apache/maven/artifact/maven-artifact/3.0-alpha-2-SNAPSHOT/

You could use this artifact as

<groupId>org.apache.maven.artifact</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0-alpha-2-SNAPSHOT</version>

which would change it each time a new snapshot is deployed or you could use

<groupId>org.apache.maven.artifact</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0-alpha-2-20090214.020928-1</version>

which would stay the same. Keep however in mind that a snapshot repository is NOT static by nature and these artifacts could potentially disappear completely. Only do that if you are using an internal repository server that you can control and therefore ensure that those snapshots don't disappear on you.

Another way to do it is to actually cut a release and use that..

Upvotes: 3

khmarbaise
khmarbaise

Reputation: 97379

You can use the versions maven plugin to pin to a particular version of SNAPSHOT which is only valid as long as the SNAPSHOT is available in the appropriate repository. But i would recommend to use a repository manager and get the SNAPSHOT's into a local repository and work with them instead. What's also possible is to get a particular SNAPSHOT and make an internal release out of it for exmaple 4.0.1-INTERNAL like and make longer available based on that.

Upvotes: 3

Related Questions