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