Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

java - 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?

question from:https://stackoverflow.com/questions/7715321/how-to-download-snapshot-version-from-maven-snapshot-repository

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...