Maven部署:即使工件已经存在也强制部署 [英] Maven deploy: forcing the deploy even if artifact already exists

查看:222
本文介绍了Maven部署:即使工件已经存在也强制部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个项目,该项目由几个(有时是不相关的)模块和一些其他非标准的Java模块(使用ANT构建)组成.

I'm building a project, which is made up from several (sometimes unrelated) modules and some more non standard java modules (built with ANT).

每个maven模块在完成后都会部署到发布存储库中.

Each maven module is deployed to the releases repository on completion.

如果构建在中间失败,那么我可能已经部署了一些模块,因此,如果我尝试重建,由于已经部署了工件,因此新的部署尝试将失败.

If the build fails in the middle, I might have some modules already deployed, so if I try to rebuild, the new attempt to deploy will fail since the artifacts are already deployed.

是否可以强制部署,或者在再次部署之前删除已部署的工件?

Is it possible to force a deploy or instead, remove the deployed artifact before I deploy again?

推荐答案

听起来中间件管理员已将您的远程仓库实例(Nexus或Artifactory或其他)配置为不允许重新部署工件,就像@khmarbaise所说的那样,原因.可以将Nexus配置为允许具有特定角色或具有工件删除特权的用户删除工件.如果您的管理员以这种方式进行设置,则可以请求删除特权并删除有问题的工件.或者,也许Nexus管理员会同意为您这样做.

It sounds like the middleware admins have configured your remote repo instance (Nexus or Artifactory or whatever) to not allow artifact redeployment, and as @khmarbaise says there are good reasons for that. Nexus can be configured to allow artifact deletion by users in a particular role or with artifact deletion privileges. If your admins have it set up that way perhaps you can request the delete privilege and remove the offending artifacts. Or, perhaps the Nexus admin will agree to do it for you.

如果这两种方法均不可行,请尝试以下操作,以防止将来发生这种情况:

If neither of these is possible, here are some things to try which might keep this from happening in the future:

  1. 如果使用的是release插件,请先进行试运行(在release:prepare命令行上为-DdryRun=true). Maven应该报告任何错误,而无需提交SCM.
  2. 尝试首先在您的项目组上运行mvn install.这会将工件安装到本地仓库,而不是远程仓库.如果有问题,您可以从本地存储库中重拾工件,然后从头开始,重复进行直到获得完整的构建.
  3. 如果您运行的是多模块版本,则有命令行选项,允许从特定项目继续恢复Maven构建.
  4. 在Maven命令行上定义-Dmaven.deploy.skip=true.这与建议2类似,除了Maven实际上会加载&配置部署插件,它只是不会做实际部署到远程仓库.一切正常后,请删除skip属性.
  1. If you are using the release plugin, do a dry run (-DdryRun=true on the release:prepare command line) first. Maven should report any errors without committing to SCM.
  2. Try running mvn install on your group of projects first. This will install the artifacts to your local repo, not the remote. If there's a problem you can whack the artifacts out of your local repo and start from scratch, repeating until you get a complete build.
  3. If you are running a multi-module build, there are command line options that allow resuming a Maven build from a particular project forward.
  4. Define -Dmaven.deploy.skip=true on the Maven command line. This is similar to suggestion #2, except Maven will actually load & configure the deploy plugin, it just won't do the actual deploy to the remote repo. Once everything works, remove the skip property.

这篇关于Maven部署:即使工件已经存在也强制部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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