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