我正在尝试根据buildVariant更改repoKey。例如,我想设置repoKey =" ProdRepo" for release build和repoKey =" DebugRepo"用于调试版本。
示例:
artifactory {
contextUrl = "http://url.com"
publish {
repository {
repoKey = *ProdRepo/DebugRepo* //based on buildType
username = properties.getProperty('artifactory_username')
password = properties.getProperty('artifactory_password')
maven = true
}
defaults {
publishArtifacts = true
publishBuildInfo = true
publishPom = true
publications('aar')
}
}
}
请帮忙。
答案 0 :(得分:0)
好的,尝试添加如下变量:
def b_type
在buildTypes
部分中,为每种类型指定一个值:
buildTypes {
debug {
...
b_type = "Debug"
}
release {
...
b_type = "Prod"
}
}
最后在你的密钥中使用它:
repoKey = "${b_type}Repo"
答案 1 :(得分:0)
请你试试下面的配置。
适用于图书馆
artifactory {
contextUrl = "http://url.com"
publish {
repository {
android.libraryVariants.all { variant ->
println(variant.getBuildType().name)
if(variant.getBuildType().name == "debug") {
repoKey = 'debug'
} else if(variant.getBuildType().name == "release") {
repoKey = 'release'
}
}
username = properties.getProperty('artifactory_username')
password = properties.getProperty('artifactory_password')
maven = true
}
defaults {
publishArtifacts = true
publishBuildInfo = true
publishPom = true
publications('aar')
}
}
}
申请
artifactory {
contextUrl = "http://url.com"
publish {
repository {
android.applicationVariants.all { variant ->
println(variant.getBuildType().name)
if(variant.getBuildType().name == "debug") {
repoKey = 'debug'
} else if(variant.getBuildType().name == "release") {
repoKey = 'release'
}
}
username = properties.getProperty('artifactory_username')
password = properties.getProperty('artifactory_password')
maven = true
}
defaults {
publishArtifacts = true
publishBuildInfo = true
publishPom = true
publications('aar')
}
}
}