所以我有一个项目,我定期发布到 Maven 没有问题。我现在想要提供该项目的快照版本。所以我做了“mvn clean 部署”。一切正常,如下所示:
[INFO] Retriving previous build number from sonatype-nexus-snapshots
上传: https://oss.sonatype.org/content/repositories/snapshots/me/soliveirajr/menta-regex/0.9.6-SNAPSHOT/menta-regex-0.9.6-20111010.153035-2.jar< /a>
已上传 5K (menta-regex-0.9.6-20111010.153035-2.jar)
我转到我的 sonatype 管理器,我可以找到快照:
但是现在,当我尝试使用此快照作为对另一台计算机中的某些其他项目的依赖项时,我得到:
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>menta-regex</artifactId>
<version>0.9.6-SNAPSHOT</version>
</dependency>
缺少:
1) me.soliveirajr:menta-regex:jar:0.9.6-SNAPSHOT
尝试从项目网站手动下载文件。
然后,使用以下命令安装它:
mvn install:install-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
或者,如果您托管自己的存储库,则可以部署那里的文件:
mvn 部署:部署文件 -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id ]
那么如何强制 maven 将 SNAPSHOT 版本下载到我的本地(.m2)存储库?
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:
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?
发布评论
评论(3)
只需将其添加到您的 ~/.m2/settings.xml 中:
Just add this to your ~/.m2/settings.xml:
为了完整起见,我想补充一点,也可以通过修改项目的
pom.xml
来实现,只需添加到您的存储库列表中即可。
在我看来,这是比修改
~/.m2/settings.xml
更好的解决方案。其他项目参与者也可以通过 Git 使用pom.xml
文件,并允许他们下载快照。来源:这个答案
For the sake of completeness, I would like to add that it is also possible by modifying the
pom.xml
of a project, simply addto your list of repositories.
In my opinion, this is a better solution than modifying
~/.m2/settings.xml
. Thepom.xml
file will also be available for other project participants through Git and allow them to download the snapshots as well.Source: this answer
您可以在存储库配置(~/.m2/settings.xml)中启用快照:
请参阅 maven.apache .org/settings.html#Repositories 了解更多属性。
You can enable snapshots in repository config (~/.m2/settings.xml):
See maven.apache.org/settings.html#Repositories for more properties.