我正在尝试基于buildVariant更改repoKey。例如,我要为发布版本设置repoKey =“ProdRepo”,为调试版本设置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')
        }
    }
}

请帮忙。

最佳答案

OK,尝试添加一个变量,如:

def b_type

并在buildTypes部分为每种类型提供一个值:
buildTypes {
    debug {
       ...
       b_type = "Debug"
    }
    release {
       ...
       b_type = "Prod"
    }
}

最后在您的密钥中使用它:
repoKey = "${b_type}Repo"

10-07 18:40