我想使用gradle脚本将多个zip文件(来自不同目录)上传到artifactory。我可以使用下面的代码上传单个发行版。
distributions {
main {
baseName = 'sample'
contents {
from{'src/main/dist/sample'}
}
}
}
publishing {
repositories {
maven {
url "${artifactoryURL}/myFiles"
credentials {
username artifactoryUser
password artifactoryPassword
}
}
}
publications {
distribution(MavenPublication) {
groupId 'com.test'
artifactId 'sample'
version version
artifact (distZip) {
}
}
}
}
请帮助上传不同来源的多个zip文件(“src / main / dist / second”)。
答案 0 :(得分:0)
这是build.gragle的完整示例。要发布拉链,您应该运行distZip artifactoryPublish
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
}
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'distribution'
//Defining list of our distributions, every value is map which contains value and version of every distribution
def dists = [
[name:'sample', version: 1],
[name:'second', version: 1]
]
distributions {
//Creating distribution from each value of the distributions list defined above
dists.each { dist ->
"$dist.name" {
baseName = "$dist.name"
contents {
from{"src/main/dist/${dist.name}"}
}
}
}
}
//Every new distribution creates task "${distributionName}DistZip" so we make posible to run them with base task distZip
distZip.dependsOn {
tasks.findAll{ task -> task.name.endsWith('DistZip') }
}
publishing {
publications {
//Again iterating list to make publication for every distribution
dists.each { dist ->
//Every publication has name of the distibution
"$dist.name"(MavenPublication) {
groupId "test"
version = dist.version
artifactId = dist.name
artifact("$buildDir/distributions/${dist.name}.zip")
}
}
}
}
artifactory {
contextUrl = "$URL"
publish {
repository {
repoKey = 'REPO_KEY'
username = USER_NAME
password = PASSWORD
}
defaults {
//Publish every distribution to Artifactory
dists.each { dist ->
publications(dist.name)
}
}
}
}