aboutsummaryrefslogtreecommitdiffstats
path: root/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-11-29 01:41:24 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-12-03 12:59:56 +0530
commitdfee170bd813d267272d0d4a8c64a4cbef965619 (patch)
treef1ca7eeeded257f3957b94136572db9709597a6f /build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts
parent553a9e849263f3f86c2fecfdf5b98b8eb93f2fba (diff)
downloadHardenedPass-dfee170bd813d267272d0d4a8c64a4cbef965619.tar.gz
HardenedPass-dfee170bd813d267272d0d4a8c64a4cbef965619.zip
build-logic: add android convention plugins
Diffstat (limited to 'build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts')
-rw-r--r--build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts63
1 files changed, 63 insertions, 0 deletions
diff --git a/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts b/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts
new file mode 100644
index 00000000..9e38476d
--- /dev/null
+++ b/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.android-application.gradle.kts
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
+import flavors.FlavorDimensions
+import flavors.ProductFlavors
+import flavors.configureSlimTests
+import org.gradle.kotlin.dsl.configure
+
+plugins {
+ id("com.android.application")
+ id("com.github.android-password-store.android-common")
+}
+
+fun Project.isSnapshot(): Boolean {
+ with(project.providers) {
+ val workflow = environmentVariable("GITHUB_WORKFLOW").forUseAtConfigurationTime()
+ val snapshot = environmentVariable("SNAPSHOT").forUseAtConfigurationTime()
+ return workflow.isPresent || snapshot.isPresent
+ }
+}
+
+extensions.configure<BaseAppModuleExtension> {
+ val minifySwitch =
+ project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
+
+ adbOptions.installOptions("--user 0")
+
+ buildFeatures {
+ viewBinding = true
+ buildConfig = true
+ }
+
+ buildTypes {
+ named("release") {
+ isMinifyEnabled = !minifySwitch.isPresent
+ setProguardFiles(
+ listOf(
+ "proguard-android-optimize.txt",
+ "proguard-rules.pro",
+ "proguard-rules-missing-classes.pro",
+ )
+ )
+ buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "${project.isSnapshot()}")
+ }
+ named("debug") {
+ applicationIdSuffix = ".debug"
+ versionNameSuffix = "-debug"
+ isMinifyEnabled = false
+ buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "true")
+ }
+ }
+
+ flavorDimensions.add(FlavorDimensions.FREE)
+ productFlavors {
+ register(ProductFlavors.FREE) {}
+ register(ProductFlavors.NON_FREE) {}
+ }
+
+ project.configureSlimTests()
+}