Gradle 将zip部署到nexus时出现多个工件问题
我的程序输出一个zip,我想将这个zip部署到nexus存储库。我使用gradle作为构建系统 我的配置片段:Gradle 将zip部署到nexus时出现多个工件问题,gradle,nexus,Gradle,Nexus,我的程序输出一个zip,我想将这个zip部署到nexus存储库。我使用gradle作为构建系统 我的配置片段: class DestinationFileTask extends DefaultTask { File destFile; } task generate(type: DestinationFileTask) { destFile = file('output/file.zip') } artifacts { output generate.destFil
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"
}
}
}
当我执行gradleuploadArchives
时,我收到以下错误:
> 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与错误无关,它更多地与您正在使用的插件相关。
这个错误确实具有误导性,谷歌也没有太多关于它的信息
但事实证明,这个错误的原因是Maven试图将工件上传到另一个工件之上。
因此,首先检查您正在执行的打包任务,在我的例子中:
task ':registry:bootDistTar',
task ':registry:bootDistZip',
...
task ':registry:distTar',
task ':registry:distZip',
解决方法是更改分类器(在我的spring boot应用程序中):
希望这将有助于其他人,因为这是很难弄清楚。
bootDistTar {
classifier = 'bootTar'
}
bootDistZip {
classifier = 'bootZip'
}