gpt4 book ai didi

java - 仅将 JAR 发布到 Maven 存储库

转载 作者:行者123 更新时间:2023-12-02 09:55:10 24 4
gpt4 key购买 nike

我想将生成的 jar 文件上传到 packagecloud.io。

我缩短的build.gradle:

jar {
archiveName "$project.name-$project.version-SNAPSHOT.jar"
}

distTar {
archiveName 'dist.tar'
}

//project.configurations.archives.artifacts.clear()
artifacts {
archives( file( "$buildDir/libs/$project.name-$project.version-SNAPSHOT.jar" ) )
}

uploadArchives {
repositories.mavenDeployer {
pom.version = project.version + '-SNAPSHOT'
configuration = configurations.deployerJars
repository( url:'packagecloud+https://packagecloud.io/mycompany/central' ){
authentication password:pw
}
}
}

jar.finalizedBy uploadArchives

当我运行gradlew distTar时,jar文件与tar一起生成,并上传到存储库,但构建失败并出现异常:

> Task :compileJava NO-SOURCE
> Task :compileGroovy UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar
> Task :startScripts
> Task :distTar

> Task :uploadArchives
Could not transfer artifact io.mozaiq:feature-state-verticle:pom:0.1-20190509.110559-1 from/to remote (packagecloud+https://packagecloud.io/mozaiq/central): Upload failed: {"error":"Validation failed: Unknown Java::Version::UnsupportedPackaging"}
Could not transfer artifact io.mozaiq:feature-state-verticle:tar:0.1-20190509.110559-1 from/to remote (packagecloud+https://packagecloud.io/mozaiq/central): Upload failed: {"error":"Could not understand this request, please contact support@packagecloud.io"}

> Task :uploadArchives FAILED

因此,出于某种原因,它不仅尝试上传 jar 文件,还尝试上传所有生成的工件。

如何限制仅发布到 jar 文件?

最佳答案

基于 similar question 的回答和 this post来自 Gradle 论坛:解决方案是从 archives 配置中排除所有非“jar”的工件。这样,uploadArchives 将仅上传 Jar 工件,跳过所有其他生成的工件/

configurations.archives.artifacts.removeAll{
it.extension != 'jar'
}

这与您自己的基于工件“类型”的解决方案类似。

关于java - 仅将 JAR 发布到 Maven 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56058215/

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