Kaynağa Gözat

add signing from local keystore for publish APK

MrOzOn 5 yıl önce
ebeveyn
işleme
d12a241039
2 değiştirilmiş dosya ile 30 ekleme ve 0 silme
  1. 1 0
      app/.gitignore
  2. 29 0
      app/build.gradle

+ 1 - 0
app/.gitignore

@@ -1 +1,2 @@
 /build
+/release/output.json

+ 29 - 0
app/build.gradle

@@ -17,10 +17,21 @@ android {
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }
 
+    signingConfigs {
+        release {
+            prepareProperties()
+            storeFile configStoreFile
+            storePassword configStorePassword
+            keyAlias configKeyAlias
+            keyPassword configKeyPassword
+        }
+    }
+
     buildTypes {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+            signingConfig signingConfigs.release
         }
         staging {
             minifyEnabled true
@@ -77,3 +88,21 @@ dependencies {
     implementation project(':feature_person')
     implementation project(':feature_measure_type')
 }
+
+def prepareProperties() {
+    Properties properties = new Properties()
+    String filePath = ""
+    if (System.getenv("HUDSON_HOME")!=null) {
+        filePath = System.getenv("HUDSON_HOME") + "/.keystore/keystore.properties"
+    } else {
+        filePath = System.getenv("HOME") + "/.keystore/keystore.properties"
+    }
+    System.console().println(filePath)
+    file(filePath).with { fname ->
+        properties.load(fname.newDataInputStream())
+        ext.configStoreFile = file(fname.getParent() + "/" + properties['keystore'])
+        ext.configStorePassword = properties['keystore.password']
+        ext.configKeyAlias = properties['keyAlias']
+        ext.configKeyPassword = properties['keyPassword']
+    }
+}