diff options
author | lalottacontinua <loddatio@posteo.de> | 2018-06-27 22:44:33 +0200 |
---|---|---|
committer | lalottacontinua <loddatio@posteo.de> | 2018-06-27 22:44:33 +0200 |
commit | d63dd4b36701f2f993e671f8cc3c5424b787e43a (patch) | |
tree | 486a8c3a1a688e76c7da7f5d9f8dfddbcc0b58aa /app/build.gradle | |
parent | 277f0f12ca505797daec42a5211885ac07b909f9 (diff) | |
parent | 8c9879145e588e985e5305ee2f88dfc1b6bf1d10 (diff) |
Merge branch 'master' into add_provider
Diffstat (limited to 'app/build.gradle')
-rw-r--r-- | app/build.gradle | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/app/build.gradle b/app/build.gradle index 09858cd2..e8f8b78f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,9 @@ +import java.util.concurrent.ExecutionException import java.util.regex.Matcher import java.util.regex.Pattern apply plugin: 'com.android.application' +def appName = '' android { compileSdkVersion 27 @@ -42,7 +44,7 @@ android { } } - flavorDimensions "implementation" + flavorDimensions "mode","implementation" productFlavors { production { dimension "implementation" @@ -50,6 +52,34 @@ android { insecure { dimension "implementation" } + normal { + dimension "mode" + } + //Configurations for custom branded app. + custom { + dimension "mode" + //Change the package name as needed + applicationId "org.sample.custom" + //Set app name here + appName = "Custom" + resValue "string", "app_name", appName + //Change the versionCode as needed + versionCode 1 + //Change the versionName as needed + versionName "1.0" + + //Build Config Fields for default donation details + + //This is the donation URL and should be set to the relevant donation page. + buildConfigField 'String', 'donation_url', '"https://leap.se/en/about-us/donate"' + //The field to enable donations in the app. + buildConfigField 'boolean', 'enable_donation', 'true' + //The field to enable donation reminder popup in the app if enable_donation is set to 'false' this will be disabled. + buildConfigField 'boolean', 'enable_donation_reminder', 'true' + //The duration in days to trigger the donation reminder + buildConfigField 'int', 'donation_reminder_duration', '30' + + } } buildTypes { @@ -340,3 +370,41 @@ def getCurrentFlavorForBetaOrRelease() { return ""; } } + +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) && + 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 = 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 |