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 urlFile('https://gateway.pinata.cloud/ipfs/QmeqMiLxHi8AAjXobxr3QTfa1bSSLyAu86YviAqQnjxCjM/libwebrtc.aar', 'libwebrtc.aar')
114    // INSERT
115}
116
117ext {
118    travisBuild = System.getenv("TRAVIS") == "true"
119    preDexEnabled = System.getProperty("pre-dex", "true")
120    abiCodes = ['armeabi-v7a': 1, 'x86': 2, 'x86_64': 3, 'arm64-v8a': 4]
121}
122
123android {
124    namespace 'eu.siacs.conversations'
125    compileSdkVersion 32
126
127    defaultConfig {
128        minSdkVersion 21
129        targetSdkVersion 30
130        versionCode 42024 + tags.size()
131        versionName grgit.describe(always: true)
132        applicationId "eu.siacs.conversations"
133        resValue "string", "applicationId", applicationId
134        def appName = "Conversations"
135        resValue "string", "app_name", appName
136        buildConfigField "String", "APP_NAME", "\"$appName\"";
137        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
138    }
139
140
141    configurations {
142        implementation.exclude group: 'org.jetbrains' , module:'annotations'
143    }
144
145    dataBinding {
146        enabled true
147    }
148
149    compileOptions {
150        coreLibraryDesugaringEnabled true
151        sourceCompatibility JavaVersion.VERSION_1_8
152        targetCompatibility JavaVersion.VERSION_1_8
153    }
154
155    flavorDimensions("mode", "distribution")
156
157    productFlavors {
158
159        quicksy {
160            dimension "mode"
161            applicationId = "im.quicksy.client"
162            resValue "string", "applicationId", applicationId
163
164            def appName = "Quicksy"
165            resValue "string", "app_name", appName
166            buildConfigField "String", "APP_NAME", "\"$appName\"";
167        }
168
169        conversations {
170            dimension "mode"
171        }
172
173        cheogram {
174            dimension "mode"
175
176            applicationId = "com.cheogram.android"
177            resValue "string", "applicationId", applicationId
178
179            def appName = "Cheogram"
180            resValue "string", "app_name", appName
181            buildConfigField "String", "APP_NAME", "\"$appName\"";
182        }
183
184        playstore {
185            dimension "distribution"
186            versionNameSuffix "+playstore"
187        }
188        free {
189            dimension "distribution"
190            versionNameSuffix "+free"
191        }
192    }
193
194    sourceSets {
195        quicksyFree {
196            java {
197                srcDir 'src/quicksyFree/java'
198            }
199        }
200        quicksyPlaystore {
201            java {
202                srcDir 'src/quicksyPlaystore/java'
203            }
204            res {
205                srcDir 'src/quicksyPlaystore/res'
206            }
207        }
208        conversationsFree {
209            java {
210                srcDir 'src/conversationsFree/java'
211            }
212        }
213        cheogramFree {
214            java {
215                srcDir 'src/conversationsFree/java'
216            }
217        }
218        conversationsPlaystore {
219            java {
220                srcDir 'src/conversationsPlaystore/java'
221            }
222            res {
223                srcDir 'src/conversationsPlaystore/res'
224            }
225        }
226    }
227
228    buildTypes {
229        release {
230            shrinkResources true
231            minifyEnabled true
232            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
233        }
234        debug {
235            shrinkResources true
236            minifyEnabled true
237            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
238        }
239    }
240
241
242    if (new File("signing.properties").exists()) {
243        Properties props = new Properties()
244        props.load(new FileInputStream(file("signing.properties")))
245
246        signingConfigs {
247            release {
248                storeFile file(props['keystore'])
249                storePassword props['keystore.password']
250                keyAlias props['keystore.alias']
251                keyPassword props['keystore.password']
252            }
253        }
254        buildTypes.release.signingConfig = signingConfigs.release
255    }
256
257    lintOptions {
258        disable 'MissingTranslation', 'InvalidPackage','AppCompatResource'
259        abortOnError false
260    }
261
262    subprojects {
263
264        afterEvaluate {
265            if (getPlugins().hasPlugin('android') ||
266                    getPlugins().hasPlugin('android-library')) {
267
268                configure(android.lintOptions) {
269                    disable 'AndroidGradlePluginVersion', 'MissingTranslation'
270                    abortOnError false
271                }
272            }
273
274        }
275    }
276    packagingOptions {
277        resources {
278            excludes += ['META-INF/BCKEY.DSA', 'META-INF/BCKEY.SF']
279        }
280    }
281    lint {
282        disable 'MissingTranslation', 'InvalidPackage', 'AppCompatResource'
283    }
284
285    android.applicationVariants.all { variant ->
286        variant.outputs.each { output ->
287            def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
288            if (baseAbiVersionCode != null) {
289                output.versionCodeOverride = (100 * project.android.defaultConfig.versionCode) + baseAbiVersionCode
290            } else {
291                output.versionCodeOverride = (100 * project.android.defaultConfig.versionCode) + grgit.log(includes: ["HEAD"], excludes: [tags.last()]).size()
292            }
293        }
294
295    }
296}