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