@@ -6,7 +6,7 @@ android {
6
6
compileSdk 31
7
7
8
8
defaultConfig {
9
- applicationId " eu.vcmi .vcmi"
9
+ applicationId " is.xyz .vcmi"
10
10
minSdk 21
11
11
targetSdk 31
12
12
versionCode 1
@@ -26,10 +26,17 @@ android {
26
26
abiFilters. addAll(VCMI_ABIS )
27
27
}
28
28
}
29
+
30
+ signingConfigs {
31
+ releaseSigning
32
+ LoadSigningConfig (PROJECT_PATH_BASE )
33
+ }
29
34
30
35
buildTypes {
31
36
release {
32
37
minifyEnabled false
38
+ zipAlignEnabled true
39
+ signingConfig signingConfigs. releaseSigning
33
40
proguardFiles getDefaultProguardFile(' proguard-android-optimize.txt' ), ' proguard-rules.pro'
34
41
}
35
42
}
@@ -101,6 +108,86 @@ android {
101
108
}
102
109
}
103
110
111
+ def RenameOutput (final baseName , final variant ) {
112
+ final def apkPath = variant. outputs[0 ]. outputFile. parent
113
+ final def travisId = System . getenv(" TRAVIS_JOB_ID" )
114
+ ResolveGitInfo ()
115
+ def name = baseName + " -" + ext. gitInfoLauncher + " -" + ext. gitInfoVcmi
116
+
117
+ if (travisId != null && ! travisId. isEmpty()) {
118
+ name = travisId + " -" + name
119
+ }
120
+
121
+ if (! variant. buildType. name != " release" ) {
122
+ name + = " -" + variant. buildType. name
123
+ }
124
+
125
+ variant. outputs* . outputFile = new File (apkPath, name + " .apk" )
126
+ }
127
+
128
+ def CommandOutput (final cmd , final arguments , final cwd ) {
129
+ try {
130
+ new ByteArrayOutputStream (). withStream { final os ->
131
+ exec {
132
+ executable cmd
133
+ args arguments
134
+ workingDir cwd
135
+ standardOutput os
136
+ }
137
+ return os. toString(). trim()
138
+ }
139
+ }
140
+ catch (final Exception ex) {
141
+ print (" Broken: " + cmd + " " + arguments + " in " + cwd + " :: " + ex. toString())
142
+ return " "
143
+ }
144
+ }
145
+
146
+ def ResolveGitInfo () {
147
+ if (ext. gitInfoLauncher != " none" && ext. gitInfoVcmi != " none" ) {
148
+ return
149
+ }
150
+ ext. gitInfoLauncher = CommandOutput (" git" , [" describe" , " --match=" , " --always" , " --abbrev=7" ], PROJECT_PATH_BASE )
151
+ ext. gitInfoVcmi =
152
+ CommandOutput (" git" , [" rev-parse" , " --abbrev-ref" , " HEAD" ], PROJECT_PATH_BASE + " /ext/vcmi" ). replaceAll(" [^a-zA-Z0-9\\ -_]" , " _" ) +
153
+ " -" +
154
+ CommandOutput (" git" , [" describe" , " --match=" , " --always" , " --abbrev=7" ], PROJECT_PATH_BASE + " /ext/vcmi" )
155
+ }
156
+
157
+ def SigningPropertiesPath (final basePath ) {
158
+ return file(basePath + " /.github/CI/signing.properties" )
159
+ }
160
+
161
+ def SigningKeystorePath (final basePath , final keystoreFileName ) {
162
+ return file(basePath + " /.github/CI/" + keystoreFileName)
163
+ }
164
+
165
+ def LoadSigningConfig (final basePath ) {
166
+ final def props = new Properties ()
167
+ final def propFile = SigningPropertiesPath (basePath)
168
+ if (propFile. canRead()) {
169
+ props. load(new FileInputStream (propFile))
170
+
171
+ if (props != null
172
+ && props. containsKey(' STORE_FILE' )
173
+ && props. containsKey(' STORE_PASSWORD' )
174
+ && props. containsKey(' KEY_ALIAS' )
175
+ && props. containsKey(' KEY_PASSWORD' )) {
176
+
177
+ android. signingConfigs. releaseSigning. storeFile = SigningKeystorePath (basePath, props[' STORE_FILE' ])
178
+ android. signingConfigs. releaseSigning. storePassword = props[' STORE_PASSWORD' ]
179
+ android. signingConfigs. releaseSigning. keyAlias = props[' KEY_ALIAS' ]
180
+ android. signingConfigs. releaseSigning. keyPassword = props[' KEY_PASSWORD' ]
181
+ } else {
182
+ println (" Some props from signing file are missing" )
183
+ android. buildTypes. release. signingConfig = null
184
+ }
185
+ } else {
186
+ println (" file with signing properties is missing" )
187
+ android. buildTypes. release. signingConfig = null
188
+ }
189
+ }
190
+
104
191
dependencies {
105
192
implementation ' androidx.appcompat:appcompat:1.2.0'
106
193
implementation ' com.google.android.material:material:1.3.0'
0 commit comments