build.gradle

  1// Top-level build file where you can add configuration options common to all
  2// sub-projects/modules.
  3buildscript {
  4    repositories {
  5        google()
  6        mavenCentral()
  7    }
  8    dependencies {
  9        classpath 'com.android.tools.build:gradle:7.2.2'
 10    }
 11}
 12
 13plugins {
 14    id 'org.ajoberstar.grgit' version '4.1.1'
 15}
 16
 17apply plugin: 'com.android.application'
 18
 19repositories {
 20    google()
 21    mavenCentral()
 22    jcenter()
 23    maven { url 'https://jitpack.io' }
 24}
 25
 26// https://stackoverflow.com/a/38105112/8611
 27def urlFile = { url, name ->
 28    File file = new File("$buildDir/download/${name}")
 29    file.parentFile.mkdirs()
 30    if (!file.exists()) {
 31        new URL(url).withInputStream { downloadStream ->
 32            file.withOutputStream { fileOut ->
 33                fileOut << downloadStream
 34            }
 35        }
 36    }
 37    files(file.absolutePath)
 38}
 39
 40def tags = grgit.tag.list().findAll { it.dateTime != null }.sort { it.dateTime }
 41
 42configurations {
 43    playstoreImplementation
 44    freeImplementation
 45    conversationsFreeImplementation
 46    cheogramPlaystoreImplementation
 47    conversationsPlaystoreImplementation
 48    quicksyPlaystoreImplementation
 49    quicksyPlaystoreImplementation
 50    quicksyFreeImplementation
 51    quicksyImplementation
 52}
 53
 54dependencies {
 55    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
 56
 57    androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
 58    androidTestImplementation 'junit:junit:4.13.2'
 59    androidTestImplementation 'androidx.test:runner:1.3.0'
 60    androidTestImplementation 'androidx.test:rules:1.3.0'
 61    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
 62    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
 63
 64    implementation 'androidx.viewpager:viewpager:1.0.0'
 65
 66    playstoreImplementation('com.google.firebase:firebase-messaging:23.0.7') {
 67        exclude group: 'com.google.firebase', module: 'firebase-core'
 68        exclude group: 'com.google.firebase', module: 'firebase-analytics'
 69        exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
 70    }
 71    cheogramPlaystoreImplementation("com.android.installreferrer:installreferrer:2.2")
 72    conversationsPlaystoreImplementation("com.android.installreferrer:installreferrer:2.2")
 73    quicksyPlaystoreImplementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
 74    implementation 'org.sufficientlysecure:openpgp-api:10.0'
 75    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
 76    implementation 'androidx.appcompat:appcompat:1.5.0'
 77    implementation 'androidx.exifinterface:exifinterface:1.3.3'
 78    implementation 'androidx.cardview:cardview:1.0.0'
 79    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
 80    implementation 'com.google.android.material:material:1.4.0'
 81
 82    implementation "androidx.emoji2:emoji2:1.2.0"
 83    freeImplementation "androidx.emoji2:emoji2-bundled:1.2.0"
 84
 85    implementation 'org.bouncycastle:bcmail-jdk15on:1.64'
 86    //zxing stopped supporting Java 7 so we have to stick with 3.3.3
 87    //https://github.com/zxing/zxing/issues/1170
 88    implementation 'com.google.zxing:core:3.3.3'
 89    implementation 'de.measite.minidns:minidns-hla:0.2.4'
 90    implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
 91    implementation 'org.whispersystems:signal-protocol-android:2.6.2'
 92    implementation 'com.makeramen:roundedimageview:2.3.0'
 93    implementation "com.wefika:flowlayout:0.4.1"
 94    implementation 'com.otaliastudios:transcoder:0.10.4'
 95
 96    implementation 'org.jxmpp:jxmpp-jid:1.0.3'
 97    implementation 'org.osmdroid:osmdroid-android:6.1.11'
 98    implementation 'org.hsluv:hsluv:0.2'
 99    implementation 'org.conscrypt:conscrypt-android:2.5.2'
100    implementation 'me.drakeet.support:toastcompat:1.1.0'
101    implementation "com.leinardi.android:speed-dial:3.2.0"
102
103    implementation "com.squareup.retrofit2:retrofit:2.9.0"
104    implementation "com.squareup.retrofit2:converter-gson:2.9.0"
105    implementation "com.squareup.okhttp3:okhttp:4.10.0"
106
107    implementation 'com.google.guava:guava:31.1-android'
108    implementation 'io.michaelrocks:libphonenumber-android:8.12.49'
109    implementation 'io.github.nishkarsh:android-permissions:2.1.6'
110    implementation 'androidx.recyclerview:recyclerview:1.1.0'
111    implementation 'com.github.ipld:java-cid:v1.3.1'
112    implementation 'com.splitwise:tokenautocomplete:3.0.2'
113    implementation 'me.saket:better-link-movement-method:2.2.0'
114    implementation urlFile('https://gateway.pinata.cloud/ipfs/QmeqMiLxHi8AAjXobxr3QTfa1bSSLyAu86YviAqQnjxCjM/libwebrtc.aar', 'libwebrtc.aar')
115    // INSERT
116}
117
118ext {
119    travisBuild = System.getenv("TRAVIS") == "true"
120    preDexEnabled = System.getProperty("pre-dex", "true")
121    abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
122}
123
124android {
125    namespace 'eu.siacs.conversations'
126    compileSdkVersion 32
127
128    defaultConfig {
129        minSdkVersion 21
130        targetSdkVersion 30
131        versionCode 42024 + tags.size()
132        versionName grgit.describe(always: true)
133        applicationId "eu.siacs.conversations"
134        resValue "string", "applicationId", applicationId
135        def appName = "Conversations"
136        resValue "string", "app_name", appName
137        buildConfigField "String", "APP_NAME", "\"$appName\"";
138        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
139    }
140
141
142    configurations {
143        implementation.exclude group: 'org.jetbrains' , module:'annotations'
144    }
145
146    dataBinding {
147        enabled true
148    }
149
150    compileOptions {
151        coreLibraryDesugaringEnabled true
152        sourceCompatibility JavaVersion.VERSION_1_8
153        targetCompatibility JavaVersion.VERSION_1_8
154    }
155
156    flavorDimensions("mode", "distribution")
157
158    productFlavors {
159
160        quicksy {
161            dimension "mode"
162            applicationId = "im.quicksy.client"
163            resValue "string", "applicationId", applicationId
164
165            def appName = "Quicksy"
166            resValue "string", "app_name", appName
167            buildConfigField "String", "APP_NAME", "\"$appName\"";
168        }
169
170        conversations {
171            dimension "mode"
172        }
173
174        cheogram {
175            dimension "mode"
176
177            applicationId = "com.cheogram.android"
178            resValue "string", "applicationId", applicationId
179
180            def appName = "Cheogram"
181            resValue "string", "app_name", appName
182            buildConfigField "String", "APP_NAME", "\"$appName\"";
183        }
184
185        playstore {
186            dimension "distribution"
187            versionNameSuffix "+playstore"
188        }
189        free {
190            dimension "distribution"
191            versionNameSuffix "+free"
192        }
193    }
194
195    sourceSets {
196        quicksyFree {
197            java {
198                srcDir 'src/quicksyFree/java'
199            }
200        }
201        quicksyPlaystore {
202            java {
203                srcDir 'src/quicksyPlaystore/java'
204            }
205            res {
206                srcDir 'src/quicksyPlaystore/res'
207            }
208        }
209        conversationsFree {
210            java {
211                srcDir 'src/conversationsFree/java'
212            }
213        }
214        cheogramFree {
215            java {
216                srcDir 'src/conversationsFree/java'
217            }
218        }
219        conversationsPlaystore {
220            java {
221                srcDir 'src/conversationsPlaystore/java'
222            }
223            res {
224                srcDir 'src/conversationsPlaystore/res'
225            }
226        }
227    }
228
229    buildTypes {
230        release {
231            shrinkResources true
232            minifyEnabled true
233            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
234        }
235        debug {
236            shrinkResources true
237            minifyEnabled true
238            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
239        }
240    }
241
242
243    if (new File("signing.properties").exists()) {
244        Properties props = new Properties()
245        props.load(new FileInputStream(file("signing.properties")))
246
247        signingConfigs {
248            release {
249                storeFile file(props['keystore'])
250                storePassword props['keystore.password']
251                keyAlias props['keystore.alias']
252                keyPassword props['keystore.password']
253            }
254        }
255        buildTypes.release.signingConfig = signingConfigs.release
256    }
257
258    lintOptions {
259        disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
260        abortOnError false
261    }
262
263    subprojects {
264
265        afterEvaluate {
266            if (getPlugins().hasPlugin('android') ||
267                    getPlugins().hasPlugin('android-library')) {
268
269                configure(android.lintOptions) {
270                    disable 'AndroidGradlePluginVersion', 'MissingTranslation'
271                    abortOnError false
272                }
273            }
274
275        }
276    }
277    packagingOptions {
278        resources {
279            excludes += ['META-INF/BCKEY.DSA', 'META-INF/BCKEY.SF']
280        }
281    }
282    lint {
283        disable 'MissingTranslation', 'InvalidPackage', 'AppCompatResource'
284    }
285
286    android.applicationVariants.all { variant ->
287        variant.outputs.each { output ->
288            def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
289            if (baseAbiVersionCode != null) {
290                output.versionCodeOverride = (100 * project.android.defaultConfig.versionCode) + baseAbiVersionCode
291            } else {
292                output.versionCodeOverride = (100 * project.android.defaultConfig.versionCode) + grgit.log(includes: ["HEAD"], excludes: [tags.last()]).size()
293            }
294        }
295
296    }
297}