From 9d7896ca807ad1e794a836f8e726db12e3a36e3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Latner?= <matyas.latner@nic.cz>
Date: Tue, 14 Jun 2016 16:06:03 +0200
Subject: [PATCH] Better application id assembling

---
 android/build.gradle | 3 ++-
 build.gradle         | 9 +++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/android/build.gradle b/android/build.gradle
index ce57e8963..58840a8c1 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -26,12 +26,13 @@ android {
 
     buildTypes {
         debug {
-            applicationIdSuffix rootProject.applicationIdDebugSuffix
+            applicationIdSuffix rootProject.applicationIdBranch + rootProject.applicationIdDebugSuffix
             buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
             resValue "string", "app_name", "${tablexiaAppName}"
         }
         release {
             debuggable false
+            applicationIdSuffix rootProject.applicationIdBranch
             buildConfigField ASSETS_CHECKSUM_FIELD_TYPE, ASSETS_CHECKSUM_FIELD_NAME, rootProject.ext.assetsChecksumPattern
             resValue "string", "app_name", "${tablexiaAppName}"
         }
diff --git a/build.gradle b/build.gradle
index caf19f2bb..05dc6ccec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -47,9 +47,10 @@ allprojects {
         tablexiaAppName = getTablexiaAppName()
         tablexiaVersionName = getVersionNameFromGit()
         tablexiaVersionCode = getVersionCodeFromGit()
-        applicationIdRelease = applicationBaseId + getTablexiaAppId()
-        applicationIdDebugSuffix = getTablexiaAppId()
-        applicationIdDebug = applicationBaseId + applicationIdDebugSuffix
+        applicationIdBranch = getTablexiaAppId()
+        applicationIdRelease = applicationBaseId + applicationIdBranch
+        applicationIdDebugSuffix = '.debug'
+        applicationIdDebug = applicationIdRelease + applicationIdDebugSuffix
         applicationIdDevelSuffix = '.devel'
         applicationIdDevel = applicationBaseId + applicationIdDevelSuffix
 
@@ -261,7 +262,7 @@ def getTablexiaAppId() {
     if (project.masterBranch.equals(branchName)) {
         return ""
     } else {
-        return branchName.trim().replaceAll('-', '').replaceAll('\\.', '').toLowerCase()
+        return ".${branchName.trim().replaceAll('-', '').replaceAll('\\.', '').toLowerCase()}"
     }
 }
 
-- 
GitLab