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