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