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