gpt4 book ai didi

gradle - 没有在gradle脚本中将提到的文件(war/tar/zip)发布到 Artifactory

转载 作者:行者123 更新时间:2023-12-03 06:17:00 25 4
gpt4 key购买 nike

我写了一个gradle脚本,在其中创建zip和war文件,然后需要将其上传/发布到 Artifact ,但是问题是我在 Artifact 任务中指定了war文件,即使该文件将所有内容都发布到了zip文件中,tar和war,而不仅仅是war文件。

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'distribution'

//-- set the group for publishing
group = 'com.xxx.discovery'

/**
* Initializing GAVC settings
*/
def buildProperties = new Properties()
file("version.properties").withInputStream {
stream -> buildProperties.load(stream)
}
//add the jenkins build version to the version
def env = System.getenv()
if (env["BUILD_NUMBER"]) buildProperties.coveryadBuildVersion += "_${env["BUILD_NUMBER"]}"
version = buildProperties.coveryadBuildVersion
println "${version}"

//name is set in the settings.gradle file
group = "com.aaa.covery"
version = buildProperties.discoveryadBuildVersion
println "Building ${project.group}:${project.name}:${project.version}"

repositories {
maven {
url "http://cxxxxt.tshaaaaa.tho.com:9000/artifactory/libselease"
}
maven {
url "http://cxxxxt.tshaaa.tho.com:9000/artifactory/cache"
}
}

dependencies {
compile ([
"com.uters.omni:HermesSessionAPI:1.2",
"com.uters.proxy:ProxyResources:1.1",
"com.uters.omni:SeshataDirectory:1.0.1" ,
"com.euters.omni:CybeleInfrastructure:1.1.2",
"com.euters:JSONBus:1.4.1",
"javaee:javaee-api:5"
])
}

distributions {
main {
contents {
from {
war.outputs
}
}
}
}

// for publishing to artifactory
artifacts {
archives war
}

最佳答案

根据gradle distribution plugin documentation:

All of the files in the “src/$distribution.name/dist” directory will automatically be included in the distribution.



并且,

The distribution plugin adds the distribution archives as candidate for default publishing artifacts.



换句话说,默认情况下,所有文件都会被发布,因此这可以解释您遇到的行为。

为了解决此问题,您可能可以做的是通过显式排除不需要的文件来更准确地定义 contents copySpec,即:
distributions {
main {
contents {
exclude('**/.zip')
exclude('**/.tar')
from {
war.outputs
}
}
}
}

请注意,尽管我自己没有尝试过上述操作,所以可能需要进行一些微调。但是我相信您可以在 CopySpec Interface documentation中找到所需的数据

关于gradle - 没有在gradle脚本中将提到的文件(war/tar/zip)发布到 Artifactory ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29687270/

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