将zip部署到nexus时出现多个工件问题

时间:2017-01-03 13:44:24

标签: gradle nexus

我的程序输出一个zip,我想将此zip部署到nexus存储库。我使用gradle作为构建系统。

我的配置片段:

class DestinationFileTask extends DefaultTask {
    File destFile;
}

task generate(type: DestinationFileTask) {
    destFile = file('output/file.zip')
}

artifacts {
    output generate.destFile
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "url")
            pom.version = "1.01-SNAPSHOT"
            pom.artifactId = "ID"
            pom.groupId = "com.test.test"
        }
    }
}

当我执行gradle uploadArchives时,我收到此错误:

> Could not publish configuration 'archives'
   > A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact ID:zip:zip:null, trying to add MavenArtifact ID:zip:zip:null.

即使我第一次尝试这样做。

1 个答案:

答案 0 :(得分:0)

我在进行 Gradle 升级时遇到了同样的问题:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':registry:uploadArchives'.
> Could not publish configuration 'archives'
   > A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact registry:zip:zip:null, trying to add MavenArtifact registry:zip:zip:null.

Gradle 自行升级与错误无关,它与您使用的插件更相关。 该错误确实具有误导性,而且 Google 上也没有太多相关信息。

但事实证明,此错误的原因是 Maven 试图将工件上传到另一个之上。 因此,首先检查您正在执行的打包任务,就我而言:

task ':registry:bootDistTar',
task ':registry:bootDistZip',
...
task ':registry:distTar',
task ':registry:distZip',

修复它的解决方法是更改​​分类器(在我的情况下是 Spring Boot 应用程序):

bootDistTar {
  classifier = 'bootTar'
}

bootDistZip {
  classifier = 'bootZip'
}

希望这对其他人有所帮助,因为这很难弄清楚。 Github issue where I found the workaround.