Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

maven

nexus

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.

like image 976
Neil Avatar asked May 03 '12 07:05

Neil


People also ask

Which type of artifact is named with version and timestamp?

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.

How do I search dependency in Nexus repository?

Available in Nexus Repository Pro only To view an component's dependencies, browse the repository storage or the repository index, select a component (or a component's POM), and then click on the Maven Dependency tab.


1 Answers

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..

like image 176
Manfred Moser Avatar answered Oct 20 '22 17:10

Manfred Moser