当前的 build.gradle.kts 文件:
android {
// ...
variantFilter {
ignore = run {
val isSim = flavors[0].name == "sim"
val isNet = !isSim
val isU = flavors[1].name == "custom"
val isMain = !isU
val buildType = buildType.name
val isDebug = buildType == "debug"
val isRelease = buildType == "release"
(isSim && isRelease) ||
(isSim && isU)
}
}
}
如何在新版本的插件中创建类似的配置?
更新: 使用答案,上面的代码将如下所示:
android {
androidComponents.beforeVariants {
it.enabled = run {
val isSim = it.productFlavors[0].second == "sim"
val isNet = !isSim
val isU = it.productFlavors[1].second == "custom"
val isMain = !isU
val isDebug = it.buildType == "debug"
val isRelease = it.buildType == "release"
!((isSim && isRelease) || (isSim && isU))
}
}
}