From 797e3e5c4050d4d9ade13453c966f5132ced9bae Mon Sep 17 00:00:00 2001 From: Janak Amarasena Date: Mon, 18 Jun 2018 00:33:53 +0530 Subject: Added custom package id validation --- app/build.gradle | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index d2255f42..52ea901b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,4 @@ +import java.util.concurrent.ExecutionException import java.util.regex.Matcher import java.util.regex.Pattern @@ -366,3 +367,17 @@ def getCurrentFlavorForBetaOrRelease() { return ""; } } + +task checkApplicationIdForCustomFlavor (type: Exec ) { + def currFlavor = getCurrentFlavorForBetaOrRelease() + if(currFlavor.contains("custom")) { + android.applicationVariants.all { variant -> + def mergedFlavor = variant.mergedFlavor + if (variant.flavorName.toString().equalsIgnoreCase(currFlavor)) { + if (mergedFlavor.getApplicationId().equalsIgnoreCase("org.sample.custom")) { + throw new ExecutionException("ERROR: please change the applicationId(org.sample.custom) if you want to build a custom branded app!") + } + } + } + } +} -- cgit v1.2.3