【问题标题】:Maven handling Nexus exceptionMaven 处理 Nexus 异常
【发布时间】:2015-09-10 21:34:23
【问题描述】:

我有一个包含多个子项目(模块)的项目。更具体地说,这是一个 Eclipse 项目,具有多种功能。

问题是某个功能可能不需要对发布进行任何更改。出于这个原因,我不会提高版本号,但同一个项目中的另一个功能可能会发生变化。由于重新部署相同版本被认为是不好的做法,我在 Nexus 中禁用了该选项。

现在实际问题发生在我部署时。因此,部署任何具有新版本号的东西都可以正常工作,但是在部署旧版本时,我有点期待 maven 会发出警告,说它已经在存储库中退出,然后跳过它,但事实证明 Nexus 会响应:

Return code is: 400, ReasonPhrase:Bad Request.

这会导致 maven 在整个部署过程中失败。完整的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project xyz: Failed to deploy artifacts: Could not transfer artifact xyz:target:2.5.8.0 from/to nexus (http://host/nexus/content/repositories/releases): Failed to transfer file: http://host/nexus/content/repositories/releases/x/targets/xyz/2.5.8.0/xyz-2.5.8.0.target. Return code is: 400, ReasonPhrase:Bad Request. -> [Help 1]
build   11-Sep-2015 07:09:57    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project abc: Failed to deploy artifacts: Could not transfer artifact foo:abc:jar:2.5.8.0 from/to nexus (http://host/nexus/content/repositories/releases): Failed to transfer file: http://host/nexus/content/repositories/releases/bar/abc/2.5.8.0/abc.ocl-2.5.8.0.jar. Return code is: 400, ReasonPhrase:Bad Request. -> [Help 1]

问题是,我该如何处理这种失败/异常?我想要的是如果它已经部署然后跳过/忽略该工件的部署。

【问题讨论】:

    标签: java maven repository nexus


    【解决方案1】:

    Maven: The Complete Reference, 6.1. Maven Command Line Options, 6.1.8. Dealing with Failuremvn --help

    -fae,--fail-at-end    Only fail the build afterwards;
                          allow all non-impacted builds to
                          continue
    

    【讨论】:

    • 这工作正常,除了 maven 显示它不成功。作为 -fae 命令的一部分,有没有办法抑制特定故障?
    • @SarpKaya 我不知道。它最后被称为 fail,而不是 ignore-projects-with-errors。您可以使用-fn | --fail-never,但您不会轻易识别出“真正的”失败。你必须通过构建的输出来搜索那些。
    【解决方案2】:

    在 Maven 中,普遍接受的最佳实践是跨多模块项目使用相同的版本。即使内部没有真正改变,我也会切换到该方案并部署每个模块。

    如果您不想这样做,最好将您的项目分解为多个单独构建和发布的项目。

    您可以做的唯一解决方法是为已部署的项目设置 Maven 部署插件的跳过属性。但是,您将不得不手动管理它,因此会在您的代码库上产生额外的开销和流失。更多信息请访问https://maven.apache.org/plugins/maven-deploy-plugin/faq.html

    【讨论】:

    • 我同意这一点,但企业不同意。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多