Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download SNAPSHOT version from maven SNAPSHOT repository?

So I have a project and I do regular releases to maven without a problem. I now want to make available a SNAPSHOT version of this project. So I do 'mvn clean deploy'. Everything works as you can see below:

[INFO] Retrieving previous build number from sonatype-nexus-snapshots Uploading: https://oss.sonatype.org/content/repositories/snapshots/me/soliveirajr/menta-regex/0.9.6-SNAPSHOT/menta-regex-0.9.6-20111010.153035-2.jar 5K uploaded (menta-regex-0.9.6-20111010.153035-2.jar)

I go to my sonatype manager and I can find the snapshot: enter image description hereenter image description here

But now when I try to use this snapshot as a dependency on some other project in another machine I get:

<dependency>   <groupId>me.soliveirajr</groupId>   <artifactId>menta-regex</artifactId>   <version>0.9.6-SNAPSHOT</version> </dependency> 

Missing:

1) me.soliveirajr:menta-regex:jar:0.9.6-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command: mvn install:install-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

So how do I force maven to download the SNAPSHOT version to my local (.m2) repository?

like image 492
chrisapotek Avatar asked Oct 10 '11 15:10

chrisapotek


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

What is snapshot repository?

A snapshot repository is an off-cluster storage location for your snapshots. You must register a repository before you can take or restore snapshots.


1 Answers

Just add this to your ~/.m2/settings.xml:

<profiles>   <profile>      <id>allow-snapshots</id>         <activation><activeByDefault>true</activeByDefault></activation>      <repositories>        <repository>          <id>snapshots-repo</id>          <url>https://oss.sonatype.org/content/repositories/snapshots</url>          <releases><enabled>false</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </repository>      </repositories>    </profile> </profiles> 
like image 160
JohnPristine Avatar answered Sep 24 '22 01:09

JohnPristine