我写了一个gradle脚本,我正在创建zip和war文件,然后我需要将其上传/发布到artifactory但问题是我在我的工件任务中指定了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
}
答案 0 :(得分:0)
根据gradle distribution plugin documentation:
“src / $ distribution.name / dist”目录中的所有文件将自动包含在发行版中。
而且,
分发插件将分发存档添加为默认发布工件的候选者。
换句话说,默认情况下会发布所有文件,这样就解释了您遇到的行为。
为了解决此问题,您可以采取的措施是通过明确排除不需要的文件来更准确地定义contents
copySpec,例如:
distributions {
main {
contents {
exclude('**/.zip')
exclude('**/.tar')
from {
war.outputs
}
}
}
}
请注意,我自己并没有尝试上述内容,因此可能需要进行一些微调。不过,我相信您可以在CopySpec Interface
documentation