gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 07:45:41 25 4
gpt4 key购买 nike

我的程序输出一个 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.

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

最佳答案

我在进行 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 upgrade it self 与错误无关,它与您使用的插件有关。该错误确实具有误导性,并且在 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.

关于gradle - 将 zip 部署到 nexus 时出现多个工件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41444916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com