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