Improve huawei guarding

This commit is contained in:
andrew 2023-08-16 19:23:13 +09:30
parent d308f381d9
commit 62cd0f68f0

View File

@ -41,17 +41,6 @@ def abiPostFix = ['armeabi-v7a' : 1,
'x86_64' : 4,
'universal' : 5]
tasks.register('checkHuaweiEnabled') {
ext.huaweiEnabled = project.hasProperty('huawei')
doFirst {
if (!huaweiEnabled) {
def message = 'Huawei is not enabled. Please add -Phuawei command line arg. See README.'
logger.error(message)
throw new GradleException(message)
}
}
}
android {
compileSdkVersion androidCompileSdkVersion
namespace 'network.loki.messenger'
@ -193,9 +182,19 @@ android {
viewBinding true
}
applicationVariants.all { variant ->
def huaweiEnabled = project.properties['huawei'] != null
applicationVariants.configureEach { variant ->
if (variant.flavorName == 'huawei') {
variant.getPreBuildProvider().get().dependsOn checkHuaweiEnabled
variant.getPreBuildProvider().configure { task ->
task.doFirst {
if (!huaweiEnabled) {
def message = 'Huawei is not enabled. Please add -Phuawei command line arg. See BUILDING.md'
logger.error(message)
throw new GradleException(message)
}
}
}
}
}
}