Maven 尝试使用错误的快照版本
我正在尝试将第 3 方库的快照版本部署到我们的本地存储库(由于遗留原因,这是旧版本,不再托管在任何在线存储库中,目前我无法替换它,因此我必须在本地托管它)。
现在,我想我误解了快照的概念,所以如果有人能纠正我的话,我将非常感激。 我的 jar 名为 foo-0.5.0-20090612.124.jar,我尝试使用 maven deploy:deploy 文件将其上传到版本 0.5.0 下的 org.bar.foo。 我的 POM 中的版本依赖项是 0.5.0-SNAPSHOT
每次我将 jar 文件上传到本地存储库时,文件名中日期后面的数字都会迭代(即到 125),但是当我运行 maven install 时,maven 会尝试下载一个带有先前编号(即 124)的罐子。
那么,有什么方法可以让 Maven 下载正确的快照版本,或者我不应该将第 3 方快照文件上传到我们的存储库吗?
I'm trying to deploy the snapshot version of a 3rd party library to our local repo (for legacy reasons this is and old version which is no longer hosted at any online repo, and for the time being I can't replace it, hence I have to host it locally).
Now, I think I've misunderstood the SNAPSHOT-concept, so I'd be very thankful if somebody could set me straight. The jar I have is named foo-0.5.0-20090612.124.jar, and I try uploading it using maven deploy:deploy file to org.bar.foo under version 0.5.0.
The version dependency in my POM is 0.5.0-SNAPSHOT
Each time I upload the jar file to our local repo the number following the date in the filename is iterated (i.e to 125), but when I run maven install, maven attempts to download a jar with the previous number (i.e. 124).
So, is there any way of getting maven to download the correct snapshot version, or should I have no business uploading 3rd party SNAPSHOT files to our repo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的用例很好。 我相信 Maven 人员推荐的最佳实践是,一旦您将 jar 的快照版本上传到共享存储库,您应该停止将其视为快照,而应将其视为发布版本。
这是有道理的,因为您希望人们依赖该工件的特定版本。 该工件并未处于积极开发状态,预计不会在任何时间点任意更改,因此应将其视为发布版本。 只是一个您自己起的个人喜欢的名字,以及一个其他人认为是快照的名字。
当您请求依赖项 foo-0.5.0-SNAPSHOT 时,我不相信 Maven 会查找 foo-0.5.0-。 我相信它确实在存储库中查找 foo-0.5.0-SNAPSHOT,这就是您找不到它的原因。 (不过对此并不是 100% 确定,因为我们没有为快照添加时间戳。我们只是不断地用更新的版本覆盖 -SNAPSHOT jar。)
因此,将 foo-0.5.0-20090612.124.jar 放入您的第三方存储库(应仅包含出于上述原因的版本)。 然后在您的 pom 中,显式引用“已发布”工件 foo-0.5.0-20090612.124,一切都应该正常工作。
The use case you have is fine. I believe the best practice recommended by the Maven folks is that once you are uploading a SNAPSHOT version of a jar to a shared repository, you should stop treating it as a SNAPSHOT, and instead as a release.
This makes sense because you want people to depend on that specific version of that artifact. The artifact is not under active development and is not expected to change arbitrarily at any point in time and for that reason it should be considered a release. Just one to which you give your own personal fancy name, and one that someone else considered a SNAPSHOT.
When you ask for the dependency foo-0.5.0-SNAPSHOT, I don't believe Maven looks for foo-0.5.0-. I believe it literally looks for foo-0.5.0-SNAPSHOT in the repository, and that is why you are not finding it. (Not 100% sure about this though, as we don't timestamp our SNAPSHOTS. We simply continually overwrite -SNAPSHOT jars with newer versions as they are made.)
So, put foo-0.5.0-20090612.124.jar into your third party repository (which should only contain releases for the reason above). Then in your pom, reference the "released" artifact foo-0.5.0-20090612.124 explicitly, and everything should work fine.
我不确定我是否明白,您应该将一个名为
myartifact.jar
的工件附加到版本为0.5-SNAPSHOT
的POM
上。部署时,您的存储库应该将
-SNAPSHOT
更改为时间戳,并更新存储库元数据以反映这是最新的SNAPSHOT版本,以便它可以正确服务于快照请求。您是否使用 Archiva 或 Nexus 还是只是一个 FTP/HTTP 服务器?
I'm not sure I follow, you should have an artifact called
myartifact.jar
attached to aPOM
with a version of0.5-SNAPSHOT
.When deploying, your repository should change the
-SNAPSHOT
into a timestamp and update the repository metadata to reflect that this is the most current SNAPSHOT version, so that it can properly serve a SNAPSHOT request.Do you use a repository such as Archiva or Nexus or just a FTP/HTTP server?