1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-14 19:29:41 +01:00
NekoX/TMessagesProj/build.gradle

432 lines
12 KiB
Groovy

import cn.hutool.core.io.FileUtil
import cn.hutool.json.JSONObject
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
def verName = "7.0-preview-01"
def verCode = 63
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
def beta = verName.contains("preview")
if (serviceAccountCredentialsFile.isFile()) {
setupPlay(beta)
play.serviceAccountCredentials = serviceAccountCredentialsFile
} else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) {
setupPlay(beta)
}
void setupPlay(boolean beta) {
apply plugin: 'com.github.triplet.play'
play {
track = beta ? "beta" : "production"
defaultToAppBundles = true
userFraction = 1
}
}
configurations {
compile.exclude module: 'support-v4'
}
def okHttpVersion = '4.8.1'
def fcmVersion = '20.2.4'
def crashlyticsVersion = '17.2.1'
def playCoreVersion = '1.8.0'
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'cn.hutool:hutool-all:5.3.10'
}
}
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
implementation 'androidx.core:core-ktx:1.5.0-alpha01'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.2.0'
implementation "androidx.interpolator:interpolator:1.0.0"
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.sharetarget:sharetarget:1.0.0"
// replace zxing with latest
// TODO: fix problem with android L
implementation 'com.google.zxing:core:3.4.0'
compileOnly 'org.checkerframework:checker-qual:3.6.0'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.5'
// don't change this :)
//noinspection GradleDependency
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.osmdroid:osmdroid-android:6.1.8'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion"
implementation 'dnsjava:dnsjava:3.2.2'
implementation 'org.dizitart:nitrite:3.4.2'
implementation 'cn.hutool:hutool-core:5.3.10'
implementation 'cn.hutool:hutool-crypto:5.3.10'
implementation project(":openpgp-api")
compileOnly files('libs/libv2ray.aar')
compileOnly "com.google.firebase:firebase-messaging:$fcmVersion"
compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
compileOnly "com.google.android.play:core:$playCoreVersion"
compileOnly 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
compileOnly 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion"
releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
releaseImplementation "com.google.android.play:core:$playCoreVersion"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
}
task writeUpdateInfo {
def info = new JSONObject()
info.set("version", verName)
info.set("versionCode", verCode)
info.set("defaultFlavor", "full")
info.set("defaultApkName", "NekoX-full-arm64-v8a-release.apk.xz")
FileUtil.writeUtf8String(info.toStringPretty(), new File("build/update.json"))
}
tasks.findByName("preBuild").finalizedBy(writeUpdateInfo)
android {
compileSdkVersion 30
buildToolsVersion '30.0.1'
ndkVersion rootProject.ext.ndkVersion
defaultConfig.applicationId = "nekox.messenger"
defaultConfig {
minSdkVersion 16
//noinspection OldTargetApi
targetSdkVersion 28
versionName verName
versionCode verCode
def appId = null
def appHash = null
//obtain your own keys at https://core.telegram.org/api/obtaining_api_id
if (project.rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID")
appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH")
}
buildConfigField 'int', 'APP_ID', appId != null ? appId : "1391584"
buildConfigField 'String', 'APP_HASH', "\"" + (appHash != null ? appHash : "355c91550b0d658cfb7ff89dcf91a08c") + "\""
externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8"
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
}
bundle {
language {
enableSplit = false
}
}
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
lintOptions {
disable 'MissingTranslation'
disable 'ExtraTranslation'
disable 'BlockedPrivateApi'
}
packagingOptions {
exclude '/fabric/**'
exclude '/META-INF/*.version'
exclude '/META-INF/*.kotlin_module'
exclude '/builddef.lst'
exclude '/*.txt'
}
dexOptions {
jumboMode = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
coreLibraryDesugaringEnabled true
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
signingConfigs {
def keystorePwd = null
def alias = null
def pwd = null
Properties properties
if (project.rootProject.file('local.properties').exists()) {
properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
} else {
def base64 = System.getenv("LOCAL_PROPERTIES")
if (base64 != null && !base64.isBlank()) {
properties = new Properties()
properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64)))
}
}
if (properties != null) {
keystorePwd = properties.getProperty("KEYSTORE_PASS")
alias = properties.getProperty("ALIAS_NAME")
pwd = properties.getProperty("ALIAS_PASS")
}
keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
alias = alias ?: System.getenv("ALIAS_NAME")
pwd = pwd ?: System.getenv("ALIAS_PASS")
release {
storeFile project.file('release.keystore')
storePassword keystorePwd
keyAlias alias
keyPassword pwd
}
}
buildTypes {
debug {
debuggable true
jniDebuggable true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
releaseNoGcm {
initWith debug
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources true
matchingFallbacks = ['debug']
signingConfig signingConfigs.release
}
release {
initWith releaseNoGcm
}
foss {
initWith release
matchingFallbacks = ['debug']
}
}
sourceSets {
main {
jni.srcDirs = ['./jni/']
}
debug {
jniLibs.srcDir 'src/main/libs'
}
releaseNoGcm {
jniLibs.srcDir 'src/main/libs'
}
release {
jniLibs.srcDir 'src/main/libs'
manifest.srcFile 'src/gservcies/AndroidManifest.xml'
}
foss {
jni.srcDirs = ['./jni/']
}
}
splits.abi {
enable true
universalApk true
}
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
dxUtilPath += ".bat"
}
flavorDimensions "version"
productFlavors {
mini {
versionNameSuffix '-mini'
}
miniNoEmoji {
versionNameSuffix '-mini-no-emoji'
}
miniAppleEmoji {
versionNameSuffix '-mini-apple-emoji'
}
miniNotoEmoji {
versionNameSuffix '-mini-noto-emoji'
}
miniTwitterEmoji {
versionNameSuffix '-mini-twitter-emoji'
}
miniFacebookEmoji {
versionNameSuffix '-mini-facebook-emoji'
}
full {}
fullNoEmoji {
versionNameSuffix '-full-no-emoji'
}
fullAppleEmoji {
versionNameSuffix '-full-apple-emoji'
}
fullNotoEmoji {
versionNameSuffix '-full-noto-emoji'
}
fullTwitterEmoji {
versionNameSuffix '-full-twitter-emoji'
}
fullFacebookEmoji {
versionNameSuffix '-full-facebook-emoji'
}
}
sourceSets.all { set ->
if (set.name.startsWith("full")) {
set.dependencies {
implementation files('libs/libv2ray.aar')
implementation files('libs/ss-rust-release.aar')
implementation files('libs/ssr-libev-release.aar')
}
}
if (set.name.matches("(mini|full).*")) {
if (set.name.contains("Apple")) {
set.dependencies {
implementation 'com.vanniktech:emoji-ios:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Noto")) {
set.dependencies {
implementation 'com.vanniktech:emoji-google:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Twitter")) {
set.dependencies {
implementation 'com.vanniktech:emoji-twitter:0.7.0-SNAPSHOT'
}
} else if (set.name.contains("Facebook")) {
set.dependencies {
implementation 'com.vanniktech:emoji-facebook:0.7.0-SNAPSHOT'
}
} else if (!set.name.contains("NoEmoji")) {
set.assets.srcDirs = ["src/main/assets", "src/emojis/blob"]
}
}
}
tasks.all { task ->
if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !task.name.contains("Foss")) {
task.enabled = false
}
if (task.name.contains("uploadCrashlyticsMappingFile")) {
enabled = false
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = outputFileName.replace("TMessagesProj", "NekoX")
}
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
tasks.all { task ->
if (task.name.startsWith('uploadCrashlyticsMappingFile')) {
task.enabled = false
} else if (((task.name.contains('Crashlytics'))) && !task.name.endsWith("Release")) {
task.enabled = false
} else if (((task.name.endsWith('GoogleServices'))) && !task.name.endsWith("ReleaseGoogleServices")) {
task.enabled = false
}
}
}