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