2011-10-10 139 views
26

所以我有一個項目,我會定期發佈給maven而不會有任何問題。我現在想要提供此項目的SNAPSHOT版本。所以我做'清潔部署'。一切正常,你可以看到如下:如何從Maven SNAPSHOT存儲庫下載SNAPSHOT版本?

[信息]檢索來自Sonatype的-關係的快照之前的版本號 上傳: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上傳(MENTA正則表達式,0.9.6-20111010.153035-2.jar)

我去我Sonatype的經理,我能找到的快照: enter image description hereenter image description here

但現在當我嘗試在另一臺機器使用此快照作爲一個依賴於其他一些項目我得到:

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

缺少:

1)me.soliveirajr:MENTA正則表達式中:jar:0.9.6-SNAPSHOT

嘗試從項目網站手動下載該文件。

然後,使用該命令來安裝它: MVN安裝:安裝文件-DgroupId = me.soliveirajr -DartifactId = MENTA正則表達式-Dversion = 0.9.6-SNAPSHOT -Dpackaging =罐子-Dfile = /路徑/要/文件

另外,如果您自行庫可以部署在那裏的文件: MVN部署:部署文件-DgroupId = me.soliveirajr -DartifactId = MENTA正則表達式-Dversion = 0.9.6-SNAPSHOT -Dpackaging = jar -Dfile =/path/to/file -Durl = [url] -DrepositoryId = [id]

那麼如何強制maven下載SNAPSHOT版本到我的本地(.m2)存儲庫?

回答

41

只需添加到您的〜/ .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> 
+1

不錯的例子,對於任何讀者:請注意,如果您正在尋找JaCoCo最新快照,請不要犯同樣的錯誤,並複製此示例。因爲它是一個插件,他們有不同的回購。看到這個答案:https://stackoverflow.com/a/46682942/1546042 –

相關問題