| 7 |
| def verCode = 700 |
| 8 |
| 9 | if (System.getenv("DEBUG_BUILD") == "true") { |
| 10 | verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1").trim().replace('\'','') |
| 11 | } |
| 12 |
| 13 | def officialVer = "9.3.3" |
| 14 | def officialCode = 3026 |
| 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 | def disableCMakeRelWithDebInfo = System.getenv("COMPILE_NATIVE") == 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 targetTask = "" |
| 65 | if (!gradle.startParameter.taskNames.isEmpty()) { |
| 66 | if (gradle.startParameter.taskNames.size == 1) { |
| 67 | targetTask = gradle.startParameter.taskNames[0].toLowerCase() |
| 68 | } |
| 69 | } |
| 70 |
| 71 | def nativeTarget = System.getenv("NATIVE_TARGET") |
| 72 | if (nativeTarget == null) nativeTarget = "" |
| 73 |
| 74 | android { |
| 75 | compileSdkVersion 32 |
| 76 | buildToolsVersion "31.0.0" |
| 77 | ndkVersion rootProject.ext.ndkVersion |
| 78 |
| 79 | defaultConfig.applicationId = "nekox.messenger" |
| 80 |
| 81 | splits { |
| 82 |
| 83 | abi { |
| 84 | if (targetTask.contains("fdroid")) { |
| 85 | enable false |
| 86 | universalApk true |
| 87 | } else { |
| 88 | if (nativeTarget.toLowerCase().equals("universal")) { |
| 89 | enable false |
| 90 | universalApk true |
| 91 | } else if (!nativeTarget.isBlank()) { |
| 92 | enable true |
| 93 | universalApk false |
| 94 | reset() |
| 95 | include nativeTarget |
| 96 | } else { |
| 97 | enable true |
| 98 | universalApk false |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 |
| 103 | } |
| 104 |
| 105 | defaultConfig { |
| 106 | minSdkVersion 19 |
| 107 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 108 | targetSdkVersion 32 |
| 109 |
| 110 | versionName verName |
| 111 | versionCode verCode |
| 112 |
| 113 | def appId = "1391584" |
| 114 | def appHash = "355c91550b0d658cfb7ff89dcf91a08c" |
| 115 |
| 116 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 117 |
| 118 | if (properties != null) { |
| 119 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 120 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 121 | } |
| 122 |
| 123 |
| 124 | buildConfigField "String", "OFFICIAL_VERSION", "\"" + officialVer + "\"" |
| 125 | buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + "" |
| 126 | buildConfigField "int", "APP_ID", appId |
| 127 | buildConfigField "String", "APP_HASH", "\"" + appHash + "\"" |
| 128 |
| 129 | externalNativeBuild { |
| 130 | cmake { |
| 131 | version "3.10.2" |
| 132 | arguments "-DANDROID_STL=c++_static", "-DANDROID_PLATFORM=android-16" |
| 133 | } |
| 134 | } |
| 135 |
| 136 | } |
| 137 |
| 138 | bundle { |
| 139 | language { |
| 140 | enableSplit = false |
| 141 | } |
| 142 | } |
| 143 |
| 144 | externalNativeBuild { |
| 145 | cmake { |
| 146 | path "jni/CMakeLists.txt" |
| 147 | } |
| 148 | } |
| 149 |
| 150 |
| 151 | dexOptions { |
| 152 | jumboMode = true |
| 153 | } |
| 154 |
| 155 | compileOptions { |
| 156 | sourceCompatibility JavaVersion.VERSION_11 |
| 157 | targetCompatibility JavaVersion.VERSION_11 |
| 158 |
| 159 | coreLibraryDesugaringEnabled true |
| 160 | } |
| 161 |
| 162 | kotlinOptions { |
| 163 | jvmTarget = JavaVersion.VERSION_11.toString() |
| 164 | } |
| 165 |
| 166 | testOptions { |
| 167 | unitTests.includeAndroidResources = true |
| 168 | } |
| 169 |
| 170 | signingConfigs { |
| 171 | release { |
| 172 | storeFile project.file("release.keystore") |
| 173 | storePassword keystorePwd |
| 174 | keyAlias alias |
| 175 | keyPassword pwd |
| 176 | } |
| 177 | } |
| 178 |
| 179 | buildTypes { |
| 180 | debug { |
| 181 | isDefault true |
| 182 | debuggable true |
| 183 | jniDebuggable true |
| 184 | multiDexEnabled true |
| 185 | zipAlignEnabled true; |
| 186 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 187 | ndk.debugSymbolLevel = "FULL" |
| 188 | } |
| 189 |
| 190 | releaseNoGcm { |
| 191 | debuggable false |
| 192 | jniDebuggable false |
| 193 | minifyEnabled true |
| 194 | shrinkResources true |
| 195 | multiDexEnabled true |
| 196 | zipAlignEnabled true |
| 197 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 198 | matchingFallbacks = ["release", "debug"] |
| 199 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 200 | } |
| 201 |
| 202 | release { |
| 203 | debuggable false |
| 204 | jniDebuggable false |
| 205 | minifyEnabled true |
| 206 | shrinkResources true |
| 207 | multiDexEnabled true |
| 208 | zipAlignEnabled true |
| 209 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 210 | matchingFallbacks = ["release", "debug"] |
| 211 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 212 | } |
| 213 |
| 214 | foss { |
| 215 | debuggable false |
| 216 | jniDebuggable false |
| 217 | minifyEnabled true |
| 218 | shrinkResources true |
| 219 | multiDexEnabled true |
| 220 | zipAlignEnabled true |
| 221 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 222 | matchingFallbacks = ["release", "debug"] |
| 223 | } |
| 224 |
| 225 | fdroidRelease { |
| 226 | initWith foss |
| 227 | matchingFallbacks = ["release", "debug"] |
| 228 | } |
| 229 | } |
| 230 |
| 231 | sourceSets { |
| 232 |
| 233 | main { |
| 234 | jni.srcDirs = [] |
| 235 | assets.srcDirs = ["src/main/assets", "src/emojis/twitter"] |
| 236 | } |
| 237 |
| 238 | debug { |
| 239 | java { |
| 240 | srcDirs "src/main/java", "src/gservcies/java" |
| 241 | } |
| 242 | jni.srcDirs = ["./jni/"] |
| 243 | manifest { |
| 244 | srcFile "src/gservcies/AndroidManifest.xml" |
| 245 | } |
| 246 | } |
| 247 |
| 248 | releaseNoGcm { |
| 249 | jni.srcDirs = [] |
| 250 | jniLibs { |
| 251 | srcDir "src/main/libs" |
| 252 | } |
| 253 | } |
| 254 |
| 255 | release { |
| 256 | java { |
| 257 | srcDirs "src/main/java", "src/gservcies/java" |
| 258 | } |
| 259 | jni.srcDirs = [] |
| 260 | jniLibs { |
| 261 | srcDir "src/main/libs" |
| 262 | } |
| 263 | manifest { |
| 264 | srcFile "src/gservcies/AndroidManifest.xml" |
| 265 | } |
| 266 | } |
| 267 |
| 268 | foss { |
| 269 | jni { |
| 270 | srcDirs = ["./jni/"] |
| 271 | } |
| 272 | } |
| 273 |
| 274 | fdroidRelease { |
| 275 | jni { |
| 276 | srcDirs = ["./jni/"] |
| 277 | } |
| 278 | jniLibs.srcDirs = [] |
| 279 | } |
| 280 |
| 281 | } |
| 282 |
| 283 | flavorDimensions "version" |
| 284 |
| 285 | productFlavors { |
| 286 | mini { |
| 287 | isDefault true |
| 288 | manifestPlaceholders = [is_full_version: "false"] |
| 289 | } |
| 290 | full { |
| 291 | manifestPlaceholders = [is_full_version: "true"] |
| 292 | } |
| 293 | miniPlay { |
| 294 | versionNameSuffix "-play" |
| 295 | versionCode verCode - 2 |
| 296 | manifestPlaceholders = [is_full_version: "false"] |
| 297 | } |
| 298 | } |
| 299 |
| 300 | sourceSets.all { set -> |
| 301 | if (set.name.startsWith("full")) { |
| 302 | set.dependencies { |
| 303 | implementation fileTree("libs") |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 |
| 308 | tasks.all { task -> |
| 309 | 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"))) { |
| 310 | task.enabled = false |
| 311 | } |
| 312 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 313 | enabled = false |
| 314 | } |
| 315 | if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo") && !targetTask.contains("fdroid")) { |
| 316 | enabled = false |
| 317 | } |
| 318 | } |
| 319 |
| 320 | applicationVariants.all { variant -> |
| 321 | variant.outputs.all { output -> |
| 322 | outputFileName = outputFileName.replace("TMessagesProj", "NekoX-v" + versionName) |
| 323 | } |
| 324 | } |
| 325 |
| 326 | } |
| 327 |
| 328 | def fcmVersion = "23.0.7" |
| 329 | def crashlyticsVersion = "18.2.12" |
| 330 | def playCoreVersion = "1.10.3" |
| 331 |
| 332 | dependencies { |
| 333 |
| 334 | implementation "androidx.browser:browser:1.4.0" |
| 335 | implementation "androidx.core:core-ktx:1.8.0" |
| 336 | implementation "androidx.palette:palette-ktx:1.0.0" |
| 337 | implementation "androidx.viewpager:viewpager:1.0.0" |
| 338 | implementation "androidx.exifinterface:exifinterface:1.3.3" |
| 339 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 340 | implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" |
| 341 | implementation "androidx.multidex:multidex:2.0.1" |
| 342 | implementation "androidx.sharetarget:sharetarget:1.2.0" |
| 343 |
| 344 | compileOnly "org.checkerframework:checker-qual:3.16.0" |
| 345 | compileOnly "org.checkerframework:checker-compat-qual:2.5.5" |
| 346 |
| 347 | // don"t change this :) |
| 348 | //noinspection GradleDependency |
| 349 | implementation "com.googlecode.mp4parser:isoparser:1.0.6" |
| 350 |
| 351 | implementation "com.google.code.gson:gson:2.8.8" |
| 352 | implementation "org.osmdroid:osmdroid-android:6.1.10" |
| 353 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21" |
| 354 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" |
| 355 |
| 356 | implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10" |
| 357 | implementation 'com.neovisionaries:nv-websocket-client:2.14' |
| 358 | implementation 'dnsjava:dnsjava:3.4.1' |
| 359 | implementation "org.dizitart:nitrite:3.4.3" |
| 360 |
| 361 | implementation "cn.hutool:hutool-core:5.7.13" |
| 362 | implementation "cn.hutool:hutool-crypto:5.7.13" |
| 363 | implementation 'cn.hutool:hutool-http:5.7.5' |
| 364 | implementation "com.jakewharton:process-phoenix:2.1.2" |
| 365 |
| 366 | compileOnly 'org.yaml:snakeyaml:1.29' |
| 367 | fullImplementation 'org.yaml:snakeyaml:1.29' |
| 368 |
| 369 | implementation project(":openpgp-api") |
| 370 |
| 371 | compileOnly fileTree("libs") |
| 372 |
| 373 | compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" |
| 374 | compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 375 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 376 |
| 377 | debugImplementation 'com.google.android.gms:play-services-maps:18.1.0' |
| 378 | debugImplementation 'com.google.android.gms:play-services-location:20.0.0' |
| 379 | releaseImplementation 'com.google.android.gms:play-services-maps:18.1.0' |
| 380 | releaseImplementation 'com.google.android.gms:play-services-location:20.0.0' |
| 381 |
| 382 | debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 383 | debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 384 | debugImplementation "com.google.android.play:core:$playCoreVersion" |
| 385 | releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 386 | releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 387 | releaseImplementation "com.google.android.play:core:$playCoreVersion" |
| 388 |
| 389 | testImplementation "junit:junit:4.13.2" |
| 390 | testImplementation "androidx.test:core:1.4.0" |
| 391 | testImplementation "org.robolectric:robolectric:4.5.1" |
| 392 |
| 393 | coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.2.0" |
| 394 |
| 395 | } |
| 396 |
| 397 | apply plugin: "com.google.gms.google-services" |
| 398 | apply plugin: "com.google.firebase.crashlytics" |
| 399 |
| 400 | android { |
| 401 |
| 402 |
| 403 | packagingOptions { |
| 404 | jniLibs { |
| 405 | excludes += ['/fabric/**', '/META-INF/native-image/**'] |
| 406 | } |
| 407 | resources { |
| 408 | excludes += ['/fabric/**', '/META-INF/*.version', '/META-INF/*.kotlin_module', '/META-INF/native-image/**', '/builddef.lst', '/*.txt', '/DebugProbesKt.bin', '/okhttp3/internal/publicsuffix/NOTICE'] |
| 409 | } |
| 410 | } |
| 411 | namespace "org.telegram.messenger" |
| 412 | lint { |
| 413 | disable 'MissingTranslation', 'ExtraTranslation', 'BlockedPrivateApi' |
| 414 | } |
| 415 |
| 416 | tasks.all { task -> |
| 417 | if (task.name.startsWith("uploadCrashlyticsMappingFile")) { |
| 418 | task.enabled = false |
| 419 | } else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) { |
| 420 | task.enabled = false |
| 421 | } else if (task.name.endsWith("GoogleServices") && task.name.contains("NoGcm")) { |
| 422 | task.enabled = false |
| 423 | } |
| 424 | } |
| 425 |
| 426 | } |
| 427 |