summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJanak Amarasena <janakamarasena@gmail.com>2018-06-18 20:27:30 +0530
committerJanak Amarasena <janakamarasena@gmail.com>2018-06-23 09:33:02 +0530
commitd468147c8d7a99dbac48a68f8377444fc1a9fe30 (patch)
treebd12deca0d7ea1bef2014ad2c65e7e5bb9f3be57 /app
parent308ae33ab3298ae7cbe5837a6bf15ccd63e3be2c (diff)
Minor updates according to received feedback
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle50
1 files changed, 33 insertions, 17 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 3eb948bb..5133b862 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -52,13 +52,14 @@ android {
insecure {
dimension "implementation"
}
- dafualt {
+ defualt {
dimension "mode"
}
+ //Configurations for custom branded app.
custom {
dimension "mode"
//Change the package name as needed
- applicationId "org.sample.customs"
+ applicationId "org.sample.custom"
//Set app name here
appName = "Custom"
resValue "string", "app_name", appName
@@ -370,25 +371,40 @@ def getCurrentFlavorForBetaOrRelease() {
}
}
-task checkApplicationIdForCustomFlavor (type: Exec ) {
- def currFlavor = getCurrentFlavorForBetaOrRelease()
- if(currFlavor.contains("custom")) {
+def getCurrentFlavor() {
+ Gradle gradle = getGradle()
+ String tskReqStr = gradle.getStartParameter().getTaskRequests().toString()
+
+ Pattern pattern;
+
+ if (tskReqStr.contains("assemble"))
+ pattern = Pattern.compile("assemble(\\w+)(Beta|Release|Debug)")
+ else
+ pattern = Pattern.compile("generate(\\w+)(Beta|Release|Debug)")
+
+ Matcher matcher = pattern.matcher(tskReqStr)
+
+ if (matcher.find())
+ return matcher.group(1).toLowerCase()
+ else {
+ return "";
+ }
+}
+
+task checkApplicationIdForCustomFlavor(type: Exec) {
+ def currFlavor = getCurrentFlavor()
+ 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!")
- }
- }
+ if (variant.flavorName.toString().equalsIgnoreCase(currFlavor) &&
+ 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!")
}
}
}
-task checkAppNameForCustomFlavor (type: Exec ) {
- def currFlavor = getCurrentFlavorForBetaOrRelease()
- if(currFlavor.contains("custom")) {
- if (appName.equalsIgnoreCase("custom")) {
- throw new ExecutionException("ERROR: please change the appName(Custom) if you want to build a custom branded app!")
- }
- }
+task checkAppNameForCustomFlavor(type: Exec) {
+ def currFlavor = getCurrentFlavor()
+ if (currFlavor.contains("custom") && appName.equalsIgnoreCase("custom"))
+ throw new ExecutionException("ERROR: please change the appName(Custom) if you want to build a custom branded app!")
} \ No newline at end of file