问题描述
我的maven工件已部署到Nexus快照存储库.在那里,它存储在正确的目录中,但是其文件名具有以下模式:
My maven artifact is deployed to a Nexus snapshot repository. There, it is stored in the correct directory, but its filenames have the following pattern:
mylibrary-1.0-20130213.125827-2.jar
但是,Maven无法下载该快照.根据错误日志,Maven似乎期望使用以下文件名:
However, Maven fails to download that snapshot. According to the error log, Maven seems to expect the following file name:
mylibrary-1.0-SNAPSHOT.jar
这些是我pom中的存储库设置:
These are the repository settings in my pom:
<repositories>
<repository>
<id>mycompany-all</id>
<url>https://servername/nexus/content/groups/mycompany/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
注意:链接组同时包含releases
和snapshots
存储库.
Note: the nexus group includes both the releases
and snapshots
repo.
我没有在settings.xml
中配置这些存储库-这是问题吗?还是我做错了什么?
I did not configure these repos in settings.xml
- is that the problem? Or what else am I doing wrong?
推荐答案
我通过将存储库添加到settings.xml
来使其工作,如下所示:
I made it work by adding the repositories to the settings.xml
like this:
<repositories>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
然后,就可以下载SNAPSHOT jar文件了.我怀疑当Maven知道它处理快照回购时,无论是否使用uniqueVersion,它都会尝试(请参阅Duncan Jones的回答).
Then, the SNAPSHOT jar files were downloaded just fine. I suspect that when Maven knows it deals with a snapshot repo, it tries both with and without uniqueVersion (see Duncan Jones' answer).
请注意,在我们的情况下,由于我们具有自定义的Maven插件,因此必须将这些块复制为pluginRepositories
.
Note that in our case these blocks had to be duplicated as pluginRepositories
because we have custom Maven plugins.
这篇关于Maven:为什么工件文件名中缺少-SNAPSHOT后缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!