用于产品风味的UploadArchives不会生成任何工件(.aar文件和pom文件)。我的flavors代码和uploadArchives代码在下面提到:
flavorDimensions “1.0.0”
productFlavors {
flavor1 {
dimension “1.0.0”
versionNameSuffix “-flavor1”
}
flavor2 {
dimension “1.0.0”
versionNameSuffix “-flavor2”
}
}
======================================
uploadArchives {
repositories {
mavenDeployer {
repository(url:“file://$buildDir/output/”)
pom {
groupId = ‘com.example.lib’
artifactId = ‘android-lib’
version = ‘1.0.0’
}
}
}
}
我甚至尝试过为pom添加过滤器和参数,如下所示:
uploadArchives {
repositories {
mavenDeployer {
repository(url: “file://$buildDir/output/”)
addFilter('flavor1Release') {artifact, file ->
(artifact.name == "flavor1Release")
}
addFilter('flavor2Release') {artifact, file ->
(artifact.name == "flavor2Release")
}
pom('flavor1Release').groupId = "com.example.lib"
pom('flavor1Release').artifactId = "flavor1Release"
pom('flavor1Release').version = "1.0.0"
pom('flavor2Release').groupId = "com.example.lib"
pom('flavor2Release').artifactId = "flavor2Release"
pom('flavor2Release').version = "1.0.0"
}
}
}
我在某些帖子中看到.aar已成功生成,但未生成其他pom文件。但是对我来说,即使是.aar文件也不会在运行uploadArchives时生成。