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

查看:25
本文介绍了如何在 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:

[ERROR] 执行目标失败org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(默认部署)在项目 HmapBasic 上:无法部署工件:无法传输神器 com.hand:HmapBasic:pom:3.0.3-RELEASE从/到 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 Artifacts 中做到这一点?

how can we do that in Azure Artifacts?

推荐答案

如何在 Azure Artifacts 中更新具有相同版本号的 Maven 依赖项

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.

查看文档:了解包的不变性.

一旦您将包的特定版本发布到提要,版本号是永久保留的.您无法上传较新的具有相同版本号的修订包,或将其删除并上传相同版本的新包.

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.

检查我的另一个线程更多信息.

希望这会有所帮助.

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

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