| 7 |
| def verCode = 200 + 3 * 3 |
| 8 |
| 9 | if (System.getenv("DEBUG_BUILD") == "true") { |
| 10 | verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1)") |
| 11 | } |
| 12 |
| 13 |
| 14 | def officialVer = "7.5.0" |
| 15 | def officialCode = 2246 |
| 16 |
| 17 | def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") |
| 18 |
| 19 | def beta = verName.contains("preview") |
| 20 |
| 21 | if (serviceAccountCredentialsFile.isFile()) { |
| 22 | setupPlay(beta) |
| 23 | play.serviceAccountCredentials = serviceAccountCredentialsFile |
| 24 | } else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) { |
| 25 | setupPlay(beta) |
| 26 | } |
| 27 |
| 28 | void setupPlay(boolean beta) { |
| 29 | apply plugin: 'com.github.triplet.play' |
| 30 | play { |
| 31 | track = beta ? "beta" : "production" |
| 32 | defaultToAppBundles = true |
| 33 | } |
| 34 | } |
| 35 |
| 36 | configurations { |
| 37 | compile.exclude module: 'support-v4' |
| 38 | } |
| 39 |
| 40 | def keystorePwd = null |
| 41 | def alias = null |
| 42 | def pwd = null |
| 43 |
| 44 | Properties properties |
| 45 | def base64 = System.getenv("LOCAL_PROPERTIES") |
| 46 | if (base64 != null && !base64.isBlank()) { |
| 47 | properties = new Properties() |
| 48 | properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) |
| 49 | } else if (project.rootProject.file('local.properties').exists()) { |
| 50 | properties = new Properties() |
| 51 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) |
| 52 | } |
| 53 |
| 54 | if (properties != null) { |
| 55 | keystorePwd = properties.getProperty("KEYSTORE_PASS") |
| 56 | alias = properties.getProperty("ALIAS_NAME") |
| 57 | pwd = properties.getProperty("ALIAS_PASS") |
| 58 | } |
| 59 |
| 60 | keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS") |
| 61 | alias = alias ?: System.getenv("ALIAS_NAME") |
| 62 | pwd = pwd ?: System.getenv("ALIAS_PASS") |
| 63 |
| 64 | def targetAbi = "" |
| 65 | if (!gradle.startParameter.taskNames.isEmpty()) { |
| 66 | if (gradle.startParameter.taskNames.size == 1) { |
| 67 | def targetTask = gradle.startParameter.taskNames[0].toLowerCase() |
| 68 | if (targetTask.contains("arm64")) { |
| 69 | targetAbi = "arm64" |
| 70 | } else if (targetTask.contains("arm")) { |
| 71 | targetAbi = "arm" |
| 72 | verCode -= 1 |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 |
| 77 | def okHttpVersion = '5.0.0-alpha.2' |
| 78 | def fcmVersion = '21.0.1' |
| 79 | def crashlyticsVersion = '17.3.1' |
| 80 | def playCoreVersion = '1.9.1' |
| 81 |
| 82 | dependencies { |
| 83 |
| 84 | implementation "androidx.browser:browser:1.3.0" |
| 85 | implementation 'androidx.core:core-ktx:1.5.0-beta02' |
| 86 | implementation 'androidx.palette:palette-ktx:1.0.0' |
| 87 | implementation 'androidx.viewpager:viewpager:1.0.0' |
| 88 | implementation 'androidx.exifinterface:exifinterface:1.3.2' |
| 89 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 90 | implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' |
| 91 | implementation 'androidx.multidex:multidex:2.0.1' |
| 92 | implementation 'androidx.sharetarget:sharetarget:1.1.0' |
| 93 |
| 94 | compileOnly 'org.checkerframework:checker-qual:3.10.0' |
| 95 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.5' |
| 96 |
| 97 | // don't change this :) |
| 98 | //noinspection GradleDependency |
| 99 | implementation 'com.googlecode.mp4parser:isoparser:1.0.6' |
| 100 |
| 101 | implementation 'com.google.code.gson:gson:2.8.6' |
| 102 | implementation 'org.osmdroid:osmdroid-android:6.1.10' |
| 103 | implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.31' |
| 104 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2' |
| 105 |
| 106 | implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" |
| 107 | implementation 'dnsjava:dnsjava:3.3.1' |
| 108 | implementation 'org.dizitart:nitrite:3.4.3' |
| 109 |
| 110 | implementation 'cn.hutool:hutool-core:5.5.9' |
| 111 | implementation 'cn.hutool:hutool-crypto:5.5.9' |
| 112 | implementation 'cn.hutool:hutool-http:5.5.9' |
| 113 |
| 114 | implementation 'org.yaml:snakeyaml:1.28' |
| 115 | implementation 'com.jakewharton:process-phoenix:2.0.0' |
| 116 |
| 117 | implementation project(":openpgp-api") |
| 118 |
| 119 | compileOnly fileTree("libs") |
| 120 |
| 121 | compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" |
| 122 | compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 123 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 124 |
| 125 | debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 126 | debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 127 | debugImplementation "com.google.android.play:core:$playCoreVersion" |
| 128 | releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 129 | releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 130 | releaseImplementation "com.google.android.play:core:$playCoreVersion" |
| 131 |
| 132 | testImplementation 'junit:junit:4.13.2' |
| 133 | testImplementation 'androidx.test:core:1.3.0' |
| 134 | testImplementation 'org.robolectric:robolectric:4.5.1' |
| 135 |
| 136 | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' |
| 137 |
| 138 | if (!targetAbi.isBlank()) { |
| 139 | implementation project(":ss-rust") |
| 140 | implementation project(":ssr-libev") |
| 141 | } |
| 142 |
| 143 | } |
| 144 |
| 145 | android { |
| 146 | compileSdkVersion 30 |
| 147 | buildToolsVersion '30.0.3' |
| 148 | ndkVersion rootProject.ext.ndkVersion |
| 149 |
| 150 | defaultConfig.applicationId = "nekox.messenger" |
| 151 |
| 152 | splits { |
| 153 |
| 154 | abi { |
| 155 |
| 156 | enable true |
| 157 | universalApk false |
| 158 |
| 159 | if (!targetAbi.isBlank()) { |
| 160 | if (targetAbi == "arm64") { |
| 161 | exclude 'x86', 'x86_64', 'armeabi-v7a' |
| 162 | } else if (targetAbi == "arm") { |
| 163 | exclude 'x86', 'x86_64', 'arm64-v8a' |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 |
| 168 | } |
| 169 |
| 170 | defaultConfig { |
| 171 | minSdkVersion 16 |
| 172 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 173 | targetSdkVersion 29 |
| 174 |
| 175 | versionName verName |
| 176 | versionCode verCode |
| 177 |
| 178 | def appId = "1391584" |
| 179 | def appHash = "355c91550b0d658cfb7ff89dcf91a08c" |
| 180 |
| 181 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 182 |
| 183 | if (properties != null) { |
| 184 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 185 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 186 | } |
| 187 |
| 188 |
| 189 | buildConfigField 'String', 'OFFICIAL_VERSION', "\"" + officialVer + "\"" |
| 190 | buildConfigField 'int', 'OFFICIAL_VERSION_CODE', officialCode + "" |
| 191 | buildConfigField 'int', 'APP_ID', appId |
| 192 | buildConfigField 'String', 'APP_HASH', "\"" + appHash + "\"" |
| 193 |
| 194 | externalNativeBuild { |
| 195 | cmake { |
| 196 | version '3.10.2' |
| 197 | arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16', "-j=16" |
| 198 | } |
| 199 | } |
| 200 |
| 201 | } |
| 202 |
| 203 | bundle { |
| 204 | language { |
| 205 | enableSplit = false |
| 206 | } |
| 207 | } |
| 208 |
| 209 | externalNativeBuild { |
| 210 | cmake { |
| 211 | path 'jni/CMakeLists.txt' |
| 212 | } |
| 213 | } |
| 214 |
| 215 | lintOptions { |
| 216 | disable 'MissingTranslation' |
| 217 | disable 'ExtraTranslation' |
| 218 | disable 'BlockedPrivateApi' |
| 219 | } |
| 220 |
| 221 | packagingOptions { |
| 222 |
| 223 | exclude '/fabric/**' |
| 224 | exclude '/META-INF/*.version' |
| 225 | exclude '/META-INF/*.kotlin_module' |
| 226 | exclude '/builddef.lst' |
| 227 | exclude '/*.txt' |
| 228 |
| 229 | } |
| 230 |
| 231 | dexOptions { |
| 232 | jumboMode = true |
| 233 | } |
| 234 |
| 235 | compileOptions { |
| 236 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 237 | targetCompatibility JavaVersion.VERSION_1_8 |
| 238 |
| 239 | coreLibraryDesugaringEnabled true |
| 240 | } |
| 241 |
| 242 | kotlinOptions { |
| 243 | jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 244 | } |
| 245 |
| 246 | testOptions { |
| 247 | unitTests.includeAndroidResources = true |
| 248 | } |
| 249 |
| 250 | signingConfigs { |
| 251 | release { |
| 252 | storeFile project.file('release.keystore') |
| 253 | storePassword keystorePwd |
| 254 | keyAlias alias |
| 255 | keyPassword pwd |
| 256 | } |
| 257 | } |
| 258 |
| 259 | buildTypes { |
| 260 | debug { |
| 261 | isDefault true |
| 262 | debuggable true |
| 263 | jniDebuggable false |
| 264 | multiDexEnabled true |
| 265 | zipAlignEnabled true |
| 266 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 267 | } |
| 268 |
| 269 | releaseNoGcm { |
| 270 | debuggable false |
| 271 | jniDebuggable false |
| 272 | minifyEnabled true |
| 273 | shrinkResources true |
| 274 | multiDexEnabled true |
| 275 | zipAlignEnabled true |
| 276 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 277 | matchingFallbacks = ['release', 'debug'] |
| 278 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 279 | } |
| 280 |
| 281 | release { |
| 282 | debuggable false |
| 283 | jniDebuggable false |
| 284 | minifyEnabled true |
| 285 | shrinkResources true |
| 286 | multiDexEnabled true |
| 287 | zipAlignEnabled true |
| 288 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 289 | matchingFallbacks = ['release', 'debug'] |
| 290 | signingConfig signingConfigs.release |
| 291 | } |
| 292 |
| 293 | foss { |
| 294 | debuggable false |
| 295 | jniDebuggable false |
| 296 | minifyEnabled true |
| 297 | shrinkResources true |
| 298 | multiDexEnabled true |
| 299 | zipAlignEnabled true |
| 300 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 301 | matchingFallbacks = ['release', 'debug'] |
| 302 | } |
| 303 |
| 304 | fdroidArmRelease { |
| 305 | initWith foss |
| 306 | matchingFallbacks = ['release', 'debug'] |
| 307 | } |
| 308 |
| 309 | fdroidArm64Release { |
| 310 | initWith foss |
| 311 | matchingFallbacks = ['release', 'debug'] |
| 312 | } |
| 313 | } |
| 314 |
| 315 | sourceSets { |
| 316 |
| 317 | main { |
| 318 | jni { |
| 319 | srcDirs = [] |
| 320 | } |
| 321 | } |
| 322 |
| 323 | debug { |
| 324 | java { |
| 325 | srcDirs 'src/main/java', 'src/gservcies/java' |
| 326 | } |
| 327 | jniLibs { |
| 328 | srcDir 'src/main/libs' |
| 329 | } |
| 330 | manifest { |
| 331 | srcFile 'src/gservcies/AndroidManifest.xml' |
| 332 | } |
| 333 | } |
| 334 |
| 335 | releaseNoGcm { |
| 336 | jniLibs { |
| 337 | srcDir 'src/main/libs' |
| 338 | } |
| 339 | } |
| 340 |
| 341 | release { |
| 342 | java { |
| 343 | srcDirs 'src/main/java', 'src/gservcies/java' |
| 344 | } |
| 345 | jniLibs { |
| 346 | srcDir 'src/main/libs' |
| 347 | } |
| 348 | manifest { |
| 349 | srcFile 'src/gservcies/AndroidManifest.xml' |
| 350 | } |
| 351 | } |
| 352 |
| 353 | foss { |
| 354 | jni { |
| 355 | srcDirs = ['./jni/'] |
| 356 | } |
| 357 | } |
| 358 |
| 359 | fdroidArmRelease { |
| 360 | jni { |
| 361 | srcDirs = ['./jni/'] |
| 362 | } |
| 363 | } |
| 364 |
| 365 | fdroidArm64Release { |
| 366 | jni { |
| 367 | srcDirs = ['./jni/'] |
| 368 | } |
| 369 | } |
| 370 |
| 371 | } |
| 372 |
| 373 | flavorDimensions "version" |
| 374 |
| 375 | productFlavors { |
| 376 | mini { |
| 377 | versionNameSuffix '-mini' |
| 378 | } |
| 379 | miniAppleEmoji { |
| 380 | versionNameSuffix '-mini' |
| 381 | } |
| 382 | full { |
| 383 | isDefault true |
| 384 | } |
| 385 | fullAppleEmoji { |
| 386 | versionNameSuffix '-full-apple-emoji' |
| 387 | } |
| 388 | fullPlay { |
| 389 | versionNameSuffix '-play' |
| 390 | versionCode verCode - 2 |
| 391 | } |
| 392 | } |
| 393 |
| 394 | sourceSets.all { set -> |
| 395 | if (set.name.startsWith("full")) { |
| 396 | set.dependencies { |
| 397 | implementation fileTree("libs") |
| 398 | } |
| 399 | } |
| 400 | if (set.name.matches("(mini|full).*")) { |
| 401 | if (set.name.contains("Apple")) { |
| 402 | set.assets.srcDirs = ["src/main/assets", "src/emojis/apple"] |
| 403 | /*} else if (set.name.contains("Twitter")) { |
| 404 | set.assets.srcDirs = ["src/main/assets", "src/emojis/twitter"]*/ |
| 405 | } else { |
| 406 | set.assets.srcDirs = ["src/main/assets", "src/emojis/twitter"] |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 |
| 411 | tasks.all { task -> |
| 412 | if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !(task.name.contains("Foss") || task.name.contains("Fdroid"))) { |
| 413 | task.enabled = false |
| 414 | } |
| 415 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 416 | enabled = false |
| 417 | } |
| 418 | } |
| 419 |
| 420 | applicationVariants.all { variant -> |
| 421 | variant.outputs.all { output -> |
| 422 | outputFileName = outputFileName.replace("TMessagesProj", "NekoX") |
| 423 | } |
| 424 | } |
| 425 |
| 426 | } |
| 427 |
| 428 | apply plugin: 'com.google.gms.google-services' |
| 429 | apply plugin: 'com.google.firebase.crashlytics' |
| 430 |
| 431 | android { |
| 432 |
| 433 | tasks.all { task -> |
| 434 | if (task.name.startsWith('uploadCrashlyticsMappingFile')) { |
| 435 | task.enabled = false |
| 436 | } else if (task.name.contains('Crashlytics') && task.name.contains("NoGcm")) { |
| 437 | task.enabled = false |
| 438 | } else if (task.name.endsWith('GoogleServices') && task.name.contains("NoGcm")) { |
| 439 | task.enabled = false |
| 440 | } |
| 441 | } |
| 442 |
| 443 | } |