From 62cd0f68f01b64da3683ec95539f5d53aa32d7a6 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 16 Aug 2023 19:23:13 +0930 Subject: [PATCH] Improve huawei guarding --- app/build.gradle | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d15bca89da..61f5601891 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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) + } + } + } } } }