From 4c8f38df729f97d8b733d687e6f2e93a820bc97d Mon Sep 17 00:00:00 2001 From: andrew Date: Tue, 15 Aug 2023 13:51:21 +0930 Subject: [PATCH] Require command line arg to include huawei dependencies --- app/build.gradle | 19 ++++++++++++++++++- build.gradle | 5 +++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 91ee23fbb4..d176cccdf1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,6 +41,16 @@ def abiPostFix = ['armeabi-v7a' : 1, 'x86_64' : 4, 'universal' : 5] +tasks.register('checkHuaweiEnabled') { + doFirst { + if (!project.hasProperty('huawei')) { + 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' @@ -143,6 +153,7 @@ android { buildConfigField "boolean", "PLAY_STORE_DISABLED", "true" buildConfigField "org.session.libsession.utilities.Device", "DEVICE", "org.session.libsession.utilities.Device.HUAWEI" buildConfigField "String", "NOPLAY_UPDATE_URL", "$ext.websiteUpdateUrl" + } website { @@ -180,6 +191,12 @@ android { dataBinding true viewBinding true } + + applicationVariants.all { variant -> + if (variant.flavorName == 'huawei') { + variant.preBuild.dependsOn checkHuaweiEnabled + } + } } dependencies { @@ -213,7 +230,7 @@ dependencies { exclude group: 'com.google.firebase', module: 'firebase-analytics' exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' } - huaweiImplementation 'com.huawei.hms:push:6.7.0.300' + if (project.hasProperty('huawei')) huaweiImplementation 'com.huawei.hms:push:6.7.0.300' implementation 'com.google.android.exoplayer:exoplayer-core:2.9.1' implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.1' implementation 'org.conscrypt:conscrypt-android:2.0.0' diff --git a/build.gradle b/build.gradle index 8e26563ee3..ebb3f5f250 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ buildscript { mavenCentral() maven { url 'https://developer.huawei.com/repo/' } } + dependencies { classpath "com.android.tools.build:gradle:$gradlePluginVersion" classpath files('libs/gradle-witness.jar') @@ -13,7 +14,7 @@ buildscript { classpath files('libs/gradle-witness.jar') classpath "com.squareup:javapoet:1.13.0" classpath "com.google.dagger:hilt-android-gradle-plugin:$daggerVersion" - classpath 'com.huawei.agconnect:agcp:1.6.0.300' + if (project.hasProperty('huawei')) classpath 'com.huawei.agconnect:agcp:1.6.0.300' } } @@ -57,7 +58,7 @@ allprojects { } jcenter() maven { url "https://jitpack.io" } - maven { url 'https://developer.huawei.com/repo/' } + if (project.hasProperty('huawei')) maven { url 'https://developer.huawei.com/repo/' } } project.ext {