summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <harsh@prjkt.io>2018-06-05 19:54:53 +0530
committerHarsh Shandilya <harsh@prjkt.io>2018-06-05 19:58:34 +0530
commit10c4fd90d00b8e00459184eed33d27e14777b50f (patch)
treeebfa380757b0abd90157984ae19d081a393b9cbc /app
parentdd64cf712cb6d4d36e535a2a6079ca0ce0e480f4 (diff)
build: Allow building release artifacts in-tree
This change avoids all need for changing any file under VCS to insert signing keys and configs for release builds. Example contents of keystore.properties ``` // Location of keystore, relative to module build.gradle, // in this case, of the app module storeFile=../wireguard.jks storePassword=b3ty0uc4nth4xxth1s keyAlias=wireguard keyPassword=4ndr01dsux ``` Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/build.gradle b/app/build.gradle
index 7284eafd..00f4cb10 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,5 +1,9 @@
apply plugin: 'com.android.application'
+// Create a variable called keystorePropertiesFile, and initialize it to your
+// keystore.properties file, in the rootProject folder.
+final def keystorePropertiesFile = rootProject.file("keystore.properties")
+
android {
buildToolsVersion '27.0.3'
compileOptions {
@@ -17,6 +21,28 @@ android {
versionCode 422
versionName '0.0.20180605'
}
+ // If the keystore file exists
+ if (keystorePropertiesFile.exists()) {
+ // Initialize a new Properties() object called keystoreProperties.
+ final def keystoreProperties = new Properties()
+
+ // Load your keystore.properties file into the keystoreProperties object.
+ keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+
+ signingConfigs {
+ release {
+ keyAlias keystoreProperties['keyAlias']
+ keyPassword keystoreProperties['keyPassword']
+ storeFile file(keystoreProperties['storeFile'])
+ storePassword keystoreProperties['storePassword']
+ }
+ }
+ }
+ buildTypes {
+ release {
+ if (keystorePropertiesFile.exists()) signingConfig signingConfigs.release
+ }
+ }
externalNativeBuild {
cmake {
path 'tools/CMakeLists.txt'