This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.gradle
executable file
·392 lines (320 loc) · 13.4 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
import com.android.build.OutputFile
apply plugin: 'com.android.application'
apply plugin: 'android-soexcluder'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android-extensions'
buildscript {
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath 'com.jween.gradle:android-soexcluder:1.1'
// Use Realm Database
classpath "io.realm:realm-gradle-plugin:5.12.0"
}
}
kapt {
correctErrorTypes = true
}
//// map for the version codes
//// x86 must have greater values than arm, see https://software.intel.com/en-us/android/articles/google-play-supports-cpu-architecture-filtering-for-multiple-apk
//// 64 bits have greater value than 32 bits
//ext.abiVersionCodes = ["armeabi-v7a": 1, "arm64-v8a": 2, "x86": 3, "x86_64": 4].withDefault { 0 }
android {
compileSdkVersion 29
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
// use the version code
versionCode rootProject.ext.versionCodeProp
versionName rootProject.ext.versionNameProp
resConfigs "en", "fr"
// Use Vector drawables
vectorDrawables.useSupportLibrary = true
// Keep abiFilter for the universalApk
ndk {
abiFilters "armeabi-v7a", "x86", 'arm64-v8a', 'x86_64'
}
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
storeFile file(project.hasProperty("RELEASE_STORE_FILE") ? RELEASE_STORE_FILE : "/dummy/path")
storePassword project.hasProperty("RELEASE_STORE_PASSWORD") ? RELEASE_STORE_PASSWORD : "dummy password"
keyAlias project.hasProperty("RELEASE_KEY_ALIAS") ? RELEASE_KEY_ALIAS : "dummy alias"
keyPassword project.hasProperty("RELEASE_KEY_PASSWORD") ? RELEASE_KEY_PASSWORD : "dummy password"
}
}
// Ref: https://developer.android.com/studio/build/configure-apk-splits.html
// splits {
// // Configures multiple APKs based on ABI.
// abi {
// // Enables building multiple APKs per ABI.
// enable true
//
// // By default all ABIs are included, so use reset() and include to specify that we only
// // want APKs for armeabi-v7a, x86, arm64-v8a and x86_64.
//
// // Resets the list of ABIs that Gradle should create APKs for to none.
// reset()
//
// // Specifies a list of ABIs that Gradle should create APKs for.
// include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
//
// // Generate a universal APK that includes all ABIs, so user who install from CI tool can use this one by default.
// universalApk true
// }
// }
// android.applicationVariants.all { variant ->
// variant.outputs.each { output ->
// def baseAbiVersionCode = project.ext.abiVersionCodes.get(output.getFilter(OutputFile.ABI))
// output.versionCodeOverride = baseAbiVersionCode * 10_000_000 + variant.versionCode
// }
// }
dexOptions {
jumboMode true
javaMaxHeapSize "2g"
}
buildTypes {
debug {
resValue "bool", "debug_mode", "true"
resValue "string", "git_revision", "\"${gitRevision()}\""
resValue "string", "git_revision_date", "\"${gitRevisionDate()}\""
resValue "string", "git_branch_name", "\"${gitBranchName()}\""
resValue "string", "build_number", rootProject.ext.buildNumberProp
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.release
resValue "bool", "debug_mode", "false"
resValue "string", "git_revision", "\"${gitRevision()}\""
resValue "string", "git_revision_date", "\"${gitRevisionDate()}\""
resValue "string", "git_branch_name", "\"${gitBranchName()}\""
resValue "string", "build_number", rootProject.ext.buildNumberProp
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// The 'base' dimension permits to deal with GooglePlay/Fdroid app
// The 'target' dimension permits to specify which platform are used
// The 'voip' flavor dimension permits to include/exclude jitsi at compilation time
// The 'pinning' flavor dimension permits to enable/disable certificate pinning with fingerprint check
flavorDimensions "base", "target", "voip", "pinning"
productFlavors {
app {
// use the version name
versionCode rootProject.ext.versionCodeProp
buildConfigField "boolean", "ALLOW_FCM_USE", "true"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
dimension "base"
}
appfdroid {
// use the version name
versionCode rootProject.ext.versionCodeProp
buildConfigField "boolean", "ALLOW_FCM_USE", "false"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""
dimension "base"
}
withvoip {
dimension "voip"
}
withoutvoip {
dimension "voip"
}
withpinning {
dimension "pinning"
}
withoutpinning {
dimension "pinning"
}
// Note: we cannot use reserved word protected, so typo the word
protecteed {
dimension "target"
applicationId "fr.gouv.tchap"
versionName rootProject.ext.versionNameProp
buildConfigField "String", "DEFAULT_PUSHER_APP_ID", "\"fr.gouv.tchap.android\""
}
preprod {
dimension "target"
applicationId "fr.gouv.rie.tchap"
versionName rootProject.ext.versionNameProp + "_b"
buildConfigField "String", "DEFAULT_PUSHER_APP_ID", "\"fr.gouv.rie.tchap.android\""
}
agent {
dimension "target"
applicationId "fr.gouv.tchap.a"
versionName rootProject.ext.versionNameProp + "_a"
buildConfigField "String", "DEFAULT_PUSHER_APP_ID", "\"fr.gouv.tchap.a.android\""
}
}
// The use of soexcluder fails currently for unknown reason on java.nio.file.NoSuchFileException.
// If a failure occurs, please comment this soexcluder block and run again the ./gradlew command
// by feeding option excludeVoipLibs:
// ex: ./gradlew assembleAppAgentWithoutvoipxxx -PexcludeVoipLibs
soexcluder {
withoutvoip {
exclude "lib/*/libjingle_peerconnection_so.so"
}
}
if (project.hasProperty("excludeVoipLibs")) {
packagingOptions {
exclude "lib/*/libjingle_peerconnection_so.so"
}
}
lintOptions {
lintConfig file("lint.xml")
}
repositories {
flatDir {
dir 'libs'
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
apply plugin: 'org.jetbrains.kotlin.android.extensions'
androidExtensions {
experimental = true
}
static def gitRevision() {
def cmd = "git rev-parse --short HEAD"
return cmd.execute().text.trim()
}
static def gitRevisionDate() {
def cmd = "git show -s --format=%ci HEAD^{commit}"
return cmd.execute().text.trim()
}
static def gitBranchName() {
def cmd = "git name-rev --name-only HEAD"
return cmd.execute().text.trim()
}
dependencies {
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Kotlin KTX
implementation 'androidx.core:core-ktx:1.0.2'
// Kotlin coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation "org.jetbrains.anko:anko-commons:0.10.8"
// Note: do not upgrade to 1.0.3 because it lead to crashes at startup on Android 16
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'me.leolin:ShortcutBadger:1.1.2@aar'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.jakewharton:butterknife:10.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt 'com.jakewharton:butterknife-compiler:10.1.0'
// Work manager
// (Java only)
implementation "android.arch.work:work-runtime:1.0.1"
// Kotlin + coroutines
implementation "android.arch.work:work-runtime-ktx:1.0.1"
// UI
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.binaryfork:spanny:1.0.4'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
// Epoxy
implementation 'com.airbnb.android:epoxy:3.7.0'
implementation 'com.airbnb.android:mvrx:1.0.1'
kapt 'com.airbnb.android:epoxy-processor:3.7.0'
// Network
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "com.google.code.gson:gson:$gson_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.12.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
implementation 'com.squareup.okio:okio:1.17.2'
// Use Glide library to display image (Gif supported)
implementation 'com.github.bumptech.glide:glide:4.9.0'
kapt 'com.github.bumptech.glide:compiler:4.9.0'
// Passphrase strength helper
implementation 'com.nulab-inc:zxcvbn:1.2.5'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.9.12'
//Alerter
implementation 'com.tapadoo.android:alerter:4.0.3'
/************* Matrix SDK management **************/
// update settings.gradle
// use the matrix SDK as external libs
implementation(name: 'matrix-sdk', ext: 'aar')
implementation(name: 'matrix-sdk-core', ext: 'aar')
implementation(name: 'matrix-sdk-crypto', ext: 'aar')
implementation(name: 'olm-sdk', ext: 'aar')
// use the matrix SDK as external dependency
//implementation 'com.github.matrix-org:matrix-android-sdk:v0.9.30'
// use the matrix SDK as a sub project
// you have to uncomment some lines in settings.gradle
//implementation project(':matrix-sdk')
//implementation project(':matrix-sdk-crypto')
//implementation project(':matrix-sdk-core')
/************* jitsi **************/
withvoipImplementation('org.jitsi.react:jitsi-meet-sdk:2.2.2')
/************* analytics **************/
// another tracking than GA
//implementation 'org.matomo.sdk:tracker:4.0.2'
/************* flavors management **************/
// app flavor only
appImplementation('com.google.firebase:firebase-messaging:20.0.0') {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
}
// appfdroid flavor only
// Test
testImplementation 'junit:junit:4.12' // Test
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test:rules:1.2.0'
testImplementation 'org.mockito:mockito-core:2.23.0'
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3' // fixes issue on linux/mac
testImplementation "org.robolectric:robolectric:4.0.2"
// Robolectric
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
}
//Ensure we never move past okhttp 3.12.x
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.squareup.okhttp3' && details.requested.name == 'okhttp') {
details.useVersion '3.12.3'
details.because '3.13+ dropped support for android <5'
}
}
}
if (!getGradle().getStartParameter().getTaskRequests().toString().contains("Appfdroid")
&& !getGradle().getStartParameter().getTaskRequests().toString().contains("assembleAndroidTest")) {
apply plugin: 'com.google.gms.google-services'
}