summaryrefslogtreecommitdiff
path: root/app/build.gradle
diff options
context:
space:
mode:
Diffstat (limited to 'app/build.gradle')
-rw-r--r--app/build.gradle174
1 files changed, 166 insertions, 8 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 7e4a6e03..0726cca8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -56,10 +56,11 @@ android {
}
}
- flavorDimensions "branding", "implementation"
+ flavorDimensions "branding", "implementation", "abi"
productFlavors {
productFlavors.all {
- ext.appName = null;
+ ext.appName = null
+ ext.splitApk = false
}
production {
dimension "implementation"
@@ -67,12 +68,13 @@ android {
insecure {
dimension "implementation"
}
+
normal {
dimension "branding"
appName = "Bitmask"
+ splitApk = true
}
-
custom {
dimension "branding"
@@ -106,10 +108,69 @@ android {
//The duration in days to trigger the donation reminder
buildConfigField 'int', 'donation_reminder_duration', '30'
+ // Build apks for each architecture, in addition to one 'fat' apk containing libraries for all all architectures
+ // enable this if you're publishing in gplay
+ ext {
+ splitApk = false
+ }
+
//**************************************************************************
//**************************************************************************
}
+
+
+ fat {
+ dimension "abi"
+ ext {
+ abiVersionCode = 0
+ abiFilter = ""
+ }
+ }
+
+ x86 {
+ dimension "abi"
+ ndk {
+ abiFilters "x86"
+ }
+ ext {
+ abiVersionCode = 1
+ abiFilter = "x86"
+ }
+ }
+
+ armv7 {
+ dimension "abi"
+ ndk {
+ abiFilters "armeabi-v7a"
+ }
+ ext {
+ abiVersionCode = 2
+ abiFilter = "armeabi-v7a"
+ }
+ }
+
+ x86_64 {
+ dimension "abi"
+ ndk {
+ abiFilters "x86_64"
+ }
+ ext {
+ abiVersionCode = 3
+ abiFilter = "x86_64"
+ }
+ }
+
+ arm64 {
+ dimension "abi"
+ ndk {
+ abiFilters "arm64-v8a"
+ }
+ ext {
+ abiVersionCode = 4
+ abiFilter = "arm64-v8a"
+ }
+ }
}
buildTypes {
@@ -120,6 +181,8 @@ android {
//runProguard true
if(signingConfigs.contains(release))
signingConfig signingConfigs.release.isSigningReady() ? signingConfigs.release : signingConfigs.debug
+ //minifyEnabled = true
+ //shrinkResources true
}
beta {
initWith release
@@ -159,8 +222,61 @@ android {
java.srcDirs += ['src/sharedTest/java']
}
}
+
+ /**
+ * BUILD VARAIANTS:
+ * =================
+ * Development builds:
+ * --------------------
+ * customProductionFatDebug -> branded development build, includes all ABIs
+ * normalProductionFatDebug -> Bitmask development build, includes all ABIS
+ * customInsecureFatDebug -> branded development build, doesn't checks certificates (for test server setup w/o valid certificates), includes all ABIs
+ * normalInsecureFatDebug -> Bitmask development build, doesn't checks certificates (for test server setup w/o valid certificates), includes all ABIs
+ *
+ * Branded Releases:
+ * -----------------
+ * customProductionFatBeta -> branded build, includes all ABI's, Beta release
+ * customProductionFatRelease -> branded build, includes all ABI's, stable release (-> F-Droid, GPlay if not splitApk is set to true)
+ *
+ * Bitmask Beta releases:
+ * ----------------------
+ * normalProductionArm64Beta -> Bitmask build, only for ABI arm64, for GPlay Beta channel with split apks (1 of 4)
+ * normalProductionArmv7Beta -> Bitmask build, only for ABI armeabi-v7a, for GPlay Beta channel with split apks (2 of 4)
+ * normalProductionX86Beta -> Bitmask build, only for ABI x86, for GPlay Beta channel with split apks (3 of 4)
+ * normalProductionX86_64Beta -> Bitmask build, only for ABI x86 64 bit, for GPlay Beta channel with split apks (4 of 4)
+ * normalProductionFatBeta -> Bitmask build, including all ABIS, for izzysoft's F-Droid repo and beta link on download page
+ *
+ * Bitmask Stable releases:
+ * ------------------------
+ * normalProductionArm64Release -> Bitmask build, only for ABI arm64, for GPlay releases with split apks (1 of 4)
+ * normalProductionArmv7Release -> Bitmask build, only for ABI armeabi-v7a, for GPlay releases with split apks (2 of 4)
+ * normalProductionX86Release -> Bitmask build, only for ABI x86, for GPlay releases with split apks (3 of 4)
+ * normalProductionX86_64Release -> Bitmask build, only for ABI x86 64 bit, for GPlay releases with split apks (4 of 4)
+ * normalProductionFatRelease -> Bitmask build, including all ABIS, for official F-Droid repo and stable link on download page
+ */
+
+ variantFilter { variant ->
+
+ def names = variant.flavors*.name
+ def buildTypeName = variant.buildType.name
+ // flavorDimensions "branding" -> 0, "implementation" -> 1, "abi" -> 2
+ def supportsSplitApk = variant.flavors[0].splitApk
+ // To check for a certain build type, use variant.buildType.name == "<buildType>"
+ if (((names.contains("insecure") && !names.contains("fat")) ||
+ (names.contains("insecure") && buildTypeName.contains("beta")) ||
+ (names.contains("insecure") && buildTypeName.contains("release")) ||
+ (buildTypeName.contains("debug") && !names.contains("fat")) ||
+ (!supportsSplitApk && !names.contains("fat")))
+ ) {
+ // Gradle ignores any variants that satisfy the conditions above.
+ setIgnore(true)
+ }
+ }
}
+
+
+
dependencies {
testImplementation 'junit:junit:4.12'
//outdated mockito-core version due to powermock dependency
@@ -205,11 +321,48 @@ dependencies {
}
android.applicationVariants.all { variant ->
+ // configure app name and apk file name for different build variants
def flavors = variant.productFlavors
- // flavorDimensions "branding" -> 0, "implementation" -> 1
+ // flavorDimensions "branding" -> 0, "implementation" -> 1, "abi" -> 2
def branding = flavors[0]
+ def trimmedAppName = branding.appName.replaceAll(' ', '')
+ def abiDimension = flavors[2]
+ def abiFilter = abiDimension.abiFilter
+ if (abiFilter.length() > 0) {
+ abiFilter = "_"+abiFilter
+ }
def buildType = variant.buildType
+ def tag = getTag()
+ if (tag.length() > 0) {
+ tag = "_"+tag
+ }
+
variant.resValue "string", "app_name", "\"${branding.appName}${buildType.appSuffix}\""
+
+ variant.outputs.all { output ->
+ output.outputFileName = "${trimmedAppName}${abiFilter}_${buildType.name}${tag}.apk"
+ }
+
+ // reconfigure version codes for split builds
+ variant.outputs.each { output ->
+ // if not a fat build
+ if (abiDimension.abiVersionCode > 0) {
+ output.versionCodeOverride = android.defaultConfig.versionCode * 1000 + abiDimension.abiVersionCode
+ }
+ }
+
+ // remove unrelated abi specific assets
+ variant.mergeAssets.doLast {
+ // if not a fat build
+ if (abiDimension.abiVersionCode > 0) {
+ def filesToDelete = fileTree(dir: variant.mergeAssets.outputDir, excludes: ["*pie_openvpn.${abiDimension.abiFilter}",
+ 'urls/',
+ '*.url',
+ '*.json',
+ '*.pem'])
+ delete(filesToDelete)
+ }
+ }
}
@@ -334,7 +487,7 @@ def removeDuplicatedStrings() {
def replaceDuplicatesForSource(File it, String type) {
def ics_openvpn_file = file(it.absolutePath.replace(type+'.xml', type+'-icsopenvpn.xml'))
if(ics_openvpn_file.exists()) {
- def ics_openvpn_strings_names = (new XmlParser()).parse(ics_openvpn_file)
+ def ics_openvpn_strings_names = new XmlParser().parse(ics_openvpn_file)
def current_file = it
ics_openvpn_strings_names.string.each {
@@ -381,11 +534,11 @@ task mergeUntranslatable(dependsOn: 'copyIcsOpenVPNFiles', type: Copy ) {
task copyIcsOpenVPNFiles(dependsOn: 'updateIcsOpenVpn') {
println "copyIcsOpenVPNFiles"
-/* copyIcsOpenVPNClasses
+ copyIcsOpenVPNClasses
copyIcsOpenVPNXml
copyIcsOpenVPNImages
//mergeUntranslatable.execute()
- removeDuplicatedStrings()*/
+ removeDuplicatedStrings()
}
task updateIcsOpenVpn( type: Exec ) {
@@ -394,6 +547,11 @@ task updateIcsOpenVpn( type: Exec ) {
}
+def getTag() {
+ String commit = "git log --pretty=format:'%h' -n 1".execute().text.trim().replaceAll("'", "")
+ return ("git describe --tags --exact-match "+ commit).execute().text.trim()
+}
+
task cleanNative( type: Delete ) {
def shouldClean = getCurrentFlavorForBetaOrRelease() == "production"
@@ -431,4 +589,4 @@ def getCurrentFlavorForBetaOrRelease() {
{
return "";
}
-} \ No newline at end of file
+}