如何在Azure Artifacts中更新具有相同版本号的Maven依赖项 [英] How to update a maven dependency with a same version number in Azure Artifacts

查看:109
本文介绍了如何在Azure Artifacts中更新具有相同版本号的Maven依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将maven专用存储库Nexus更改为Azure Artifacts。
当我们上传带有某个版本的私有Maven依赖项时,它在下面的信息中告诉我们:

We changed our maven private repository Nexus to Azure Artifacts. And when we upload a private maven dependency with a some version, it told us below info:


[错误]失败在项目HmapBasic上执行目标
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy):部署工件失败:
无法传输工件com .hand:HmapBasic:pom:3.0.3-release
from / to dev-azure-com-kohlerdevops-konnect-unified
https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/ ):
传输文件失败:
https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/com/hand /HmapBasic/3.0.3-RELEASE/HmapBasic-3.0.3-RELEASE.pom
返回代码是:409

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HmapBasic: Failed to deploy artifacts: Could not transfer artifact com.hand:HmapBasic:pom:3.0.3-RELEASE from/to dev-azure-com-kohlerdevops-konnect-unified (https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/): Failed to transfer file: https://pkgs.dev.azure.com/KohlerDevOps/_packaging/Konnect-Unified/maven/v1/com/hand/HmapBasic/3.0.3-RELEASE/HmapBasic-3.0.3-RELEASE.pom. Return code is: 409

我搜索了代码409错误。这意味着我们已经使用该版本上载了依赖项,因此无法再次上载。
我们想使用新的依赖项覆盖旧的而不更改版本(因为如果更改版本,我们所有的项目都需要更改pom.xml)

I searched the code 409 error. It means we have already uploaded the dependency with this version and we can't upload this again. We want to use the new dependency cover the old one without changing version(because if we change the version, all of our projects need to change pom.xml)

我们如何在Azure工件中做到这一点?

how can we do that in Azure Artifacts?

推荐答案


如何使用以下命令更新Maven依赖项在Azure工件中具有相同的版本号

How to update a maven dependency with a same version number in Azure Artifacts

恐怕您必须更改pom.xml,我知道这对您来说是多么令人沮丧。但这就是Azure Artifacts故意设计的,以确保生成结果的正确性。

I am afraid you have to change the pom.xml, I understand how frustrating this is for you. But this is what Azure Artifacts deliberately designed to ensure the correctness of the build results.

检查文档:了解软件包的不可变性。


将特定版本的软件包发布到Feed后,该
版本号将被永久保留。您不能上传具有相同版本号的较新
修订软件包,也不能删除该软件包,并且
可以上传具有相同版本的新软件包。

Once you publish a particular version of a package to a feed, that version number is permanently reserved. You cannot upload a newer revision package with that same version number, or delete it and upload a new package at the same version.

设计的原因:


那是因为许多软件包客户端(包括NuGet)都保留了本地缓存
台计算机上的软件包。客户端缓存了特定的
package @ version后,它将在以后的安装/恢复
请求时返回该副本。如果在服务器上,用
替换package @ version(rev 1)为新的package @ version(rev 2),则客户端将无法分辨出
的差异。客户端仍在缓存中使用旧版本。这可能会导致来自
不同机器的不确定生成结果。

That because many package clients, including NuGet, keep a local cache of packages on your machine. Once a client has cached a particular package@version, it will return that copy on future install/restore requests. If, on the server, you replace package@version (rev 1) with a new package@version (rev 2), the client is unable to tell the difference. the client still use the old version in cache. This can lead to indeterminate build results from different machines.

因此,我们无法覆盖所有已经上传
的软件包,即使我们可以不删除它们并重新上传。要解决
这个问题,唯一的方法是上传具有新
版本的软件包

So we could not overwrite all packages that have already been uploaded, even we could not delete them and re-uploaded. To resolve this issue, the only way is that upload the packages with a new version.

检查我的另一个线程了解更多信息。

Check my another thread for some more info.

希望这会有所帮助。

这篇关于如何在Azure Artifacts中更新具有相同版本号的Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆