NekoX/TMessagesProj/build.gradle

439 lines
14 KiB
Groovy
Raw Normal View History

2020-03-30 14:00:09 +02:00
import java.security.MessageDigest
import org.gradle.internal.os.OperatingSystem
2020-03-30 14:00:09 +02:00
apply plugin: 'com.android.application'
2013-10-25 17:19:00 +02:00
repositories {
mavenCentral()
2018-07-30 04:07:02 +02:00
google()
jcenter()
2013-10-25 17:19:00 +02:00
}
2016-10-11 13:57:01 +02:00
configurations {
compile.exclude module: 'support-v4'
}
2013-10-25 17:19:00 +02:00
dependencies {
2019-05-14 14:08:05 +02:00
implementation 'androidx.core:core:1.1.0-beta01'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.interpolator:interpolator:1.0.0'
implementation 'androidx.viewpager:viewpager:1.0.0'
2020-04-30 21:07:00 +02:00
implementation 'androidx.exifinterface:exifinterface:1.2.0'
2020-04-24 11:21:58 +02:00
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'com.android.support:multidex:1.0.3'
2019-05-14 14:08:05 +02:00
2019-01-23 18:03:33 +01:00
compileOnly 'org.checkerframework:checker-qual:2.5.2'
2018-08-27 10:33:11 +02:00
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
2020-01-18 12:57:04 +01:00
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.osmdroid:osmdroid-android:6.1.6'
}
//return an api key from a properties file.
def getAppId(){
Properties properties = new Properties()
properties.load(new FileInputStream("./API_KEYS"))
return properties.get("APP_ID")
}
def getAppHash(){
Properties properties = new Properties()
properties.load(new FileInputStream("./API_KEYS"))
return "\"" + properties.get("APP_HASH") + "\""
2019-06-11 07:56:33 +02:00
}
2013-10-25 17:19:00 +02:00
android {
2019-12-31 14:08:08 +01:00
compileSdkVersion 29
2020-03-30 14:00:09 +02:00
buildToolsVersion '29.0.3'
2020-05-09 03:46:28 +02:00
ndkVersion "21.1.6352462"
2017-12-08 18:35:59 +01:00
2019-06-11 07:42:45 +02:00
defaultConfig.applicationId = "tw.nekomimi.nekogram"
2015-10-29 18:10:07 +01:00
2016-10-11 13:57:01 +02:00
sourceSets.main.jniLibs.srcDirs = ['./jni/']
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
2018-07-30 04:07:02 +02:00
lintOptions {
disable 'MissingTranslation'
disable 'ExtraTranslation'
2019-09-10 12:56:11 +02:00
disable 'BlockedPrivateApi'
2018-07-30 04:07:02 +02:00
}
2017-03-31 01:58:05 +02:00
dexOptions {
jumboMode = true
}
2015-01-02 23:15:07 +01:00
compileOptions {
2018-08-27 10:33:11 +02:00
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
2015-01-02 23:15:07 +01:00
}
2013-12-20 20:25:49 +01:00
signingConfigs {
2020-01-28 08:01:42 +01:00
def keystorePwd = null
def alias = null
def pwd = null
if (project.rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
keystorePwd = properties.getProperty("RELEASE_STORE_PASSWORD")
alias = properties.getProperty("RELEASE_KEY_ALIAS")
pwd = properties.getProperty("RELEASE_KEY_PASSWORD")
}
2019-06-11 07:56:33 +02:00
release {
2015-11-26 22:04:02 +01:00
storeFile file("config/release.keystore")
2020-01-28 08:01:42 +01:00
storePassword keystorePwd != null ? keystorePwd : System.getenv("KEYSTORE_PASS")
keyAlias alias != null ? alias : System.getenv("ALIAS_NAME")
keyPassword pwd != null ? pwd : System.getenv("ALIAS_PASS")
2013-12-20 20:25:49 +01:00
}
2019-06-11 07:56:33 +02:00
debug {
storeFile file("config/release.keystore")
2020-01-28 08:01:42 +01:00
storePassword keystorePwd != null ? keystorePwd : System.getenv("KEYSTORE_PASS")
keyAlias alias != null ? alias : System.getenv("ALIAS_NAME")
keyPassword pwd != null ? pwd : System.getenv("ALIAS_PASS")
2013-12-20 20:25:49 +01:00
}
}
2019-06-11 07:56:33 +02:00
2013-12-20 20:25:49 +01:00
buildTypes {
debug {
debuggable true
2014-11-10 12:05:22 +01:00
jniDebuggable true
2013-12-20 20:25:49 +01:00
signingConfig signingConfigs.debug
2020-01-28 08:01:42 +01:00
applicationIdSuffix ".beta"
2018-07-30 04:07:02 +02:00
minifyEnabled true
2020-04-24 11:21:58 +02:00
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2013-12-20 20:25:49 +01:00
}
2019-12-31 14:08:08 +01:00
/*debugAsan {
debuggable true
jniDebuggable true
signingConfig signingConfigs.debug
applicationIdSuffix ".beta"
minifyEnabled true
multiDexEnabled true
2019-12-31 14:08:08 +01:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
packagingOptions {
doNotStrip "**.so"
}
sourceSets {
main {
jniLibs {
srcDir {
'jniLibs'
}
}
resources {
srcDir {
'jniRes'
}
}
}
}
}*/
2019-01-23 18:03:33 +01:00
HA {
debuggable false
jniDebuggable false
signingConfig signingConfigs.debug
2020-01-28 08:01:42 +01:00
applicationIdSuffix ".beta"
2019-01-23 18:03:33 +01:00
minifyEnabled true
2020-04-24 11:21:58 +02:00
multiDexEnabled true
2019-01-23 18:03:33 +01:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
2013-12-20 20:25:49 +01:00
release {
debuggable false
2014-11-10 12:05:22 +01:00
jniDebuggable false
2013-12-20 20:25:49 +01:00
signingConfig signingConfigs.release
2018-07-30 04:07:02 +02:00
minifyEnabled true
shrinkResources false
2020-01-03 17:44:17 +01:00
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2013-12-20 20:25:49 +01:00
}
}
2014-11-21 20:36:21 +01:00
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
2019-12-31 14:08:08 +01:00
/*sourceSets.debugAsan {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}*/
2019-01-23 18:03:33 +01:00
sourceSets.HA {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
2014-11-21 20:36:21 +01:00
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml'
}
2017-12-08 18:35:59 +01:00
flavorDimensions "minApi"
2016-03-16 13:26:32 +01:00
productFlavors {
2018-07-30 04:07:02 +02:00
armv7 {
ndk {
abiFilters "armeabi-v7a"
}
ext {
abiVersionCode = 1
}
}
2016-03-16 13:26:32 +01:00
x86 {
ndk {
2018-07-30 04:07:02 +02:00
abiFilters "x86"
}
ext {
abiVersionCode = 2
2016-03-16 13:26:32 +01:00
}
}
2018-07-30 04:07:02 +02:00
armv7_SDK23 {
2016-03-16 13:26:32 +01:00
ndk {
2018-07-30 04:07:02 +02:00
abiFilters "armeabi-v7a"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 3
2016-03-16 13:26:32 +01:00
}
}
2017-03-31 01:58:05 +02:00
x86_SDK23 {
ndk {
2018-07-30 04:07:02 +02:00
abiFilters "x86"
2017-03-31 01:58:05 +02:00
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
2018-07-30 04:07:02 +02:00
ext {
abiVersionCode = 4
}
2017-03-31 01:58:05 +02:00
}
2018-07-30 04:07:02 +02:00
arm64 {
2017-03-31 01:58:05 +02:00
ndk {
2018-07-30 04:07:02 +02:00
abiFilters "arm64-v8a"
}
ext {
abiVersionCode = 5
}
}
x64 {
ndk {
abiFilters "x86_64"
}
ext {
abiVersionCode = 6
}
}
arm64_SDK23 {
ndk {
abiFilters "arm64-v8a"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
2019-12-31 14:08:08 +01:00
/*sourceSets.debugAsan {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}*/
2018-07-30 04:07:02 +02:00
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
ext {
abiVersionCode = 7
}
}
x64_SDK23 {
ndk {
abiFilters "x86_64"
2017-03-31 01:58:05 +02:00
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
2018-07-30 04:07:02 +02:00
ext {
abiVersionCode = 8
}
2016-03-16 13:26:32 +01:00
}
2018-07-30 04:07:02 +02:00
afat {
2017-03-31 01:58:05 +02:00
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
2019-12-31 14:08:08 +01:00
/*sourceSets.debugAsan {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}*/
2017-03-31 01:58:05 +02:00
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
2018-07-30 04:07:02 +02:00
ext {
2020-01-23 13:58:50 +01:00
abiVersionCode = 9
2018-07-30 04:07:02 +02:00
}
2017-03-31 01:58:05 +02:00
}
2016-03-16 13:26:32 +01:00
}
2020-06-10 07:05:48 +02:00
defaultConfig.versionCode = 10 * 1989
2020-03-30 14:00:09 +02:00
def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]
def tgVoipDexClassesPath = "org/telegram/messenger/voip"
def dxUtilPath = "${sdkDirectory.path}/build-tools/${buildToolsVersion}/dx"
if (OperatingSystem.current().isWindows()) {
dxUtilPath = "${sdkDirectory.path}\\build-tools\\${buildToolsVersion}\\dx.bat"
}
2019-05-14 14:08:05 +02:00
2016-03-16 13:26:32 +01:00
applicationVariants.all { variant ->
2017-12-08 18:35:59 +01:00
variant.outputs.all { output ->
2020-02-08 14:11:49 +01:00
outputFileName = "Nekogram-${defaultConfig.versionName}-${defaultConfig.versionCode / 10}-${variant.productFlavors.get(0).name}-${buildType.name}.apk"
2019-05-14 14:08:05 +02:00
output.getProcessManifestProvider().get().doLast {
2018-07-30 04:07:02 +02:00
def abiVersion = variant.productFlavors.get(0).abiVersionCode
2019-05-14 14:08:05 +02:00
def outputDir = manifestOutputDirectory
File directory
if (outputDir instanceof File) {
directory = outputDir
} else {
directory = outputDir.get().asFile
}
String manifestPath = directory.toString() + "/AndroidManifest.xml"
2017-12-08 18:35:59 +01:00
def manifestContent = file(manifestPath).getText()
2019-05-14 14:08:05 +02:00
manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode + abiVersion))
2017-12-08 18:35:59 +01:00
file(manifestPath).write(manifestContent)
}
}
2020-03-30 14:00:09 +02:00
def assembleTgVoipDexTaskName = "assemble${variant.name.capitalize()}TgVoipDex"
task "${assembleTgVoipDexTaskName}" {
doLast {
def sourceDir = (File) android.sourceSets.main.java.srcDirs[0]
def classesDir = "${buildDir}/intermediates/javac/${variant.name}/classes"
def javaDir = "${buildDir}/intermediates/java_tgvoip/${variant.name}/java"
def tgVoipDir = new File(classesDir, tgVoipDexClassesPath)
def javaVoipDirFile = new File(javaDir, tgVoipDexClassesPath)
def tgVoipDexJavaFile = new File(javaVoipDirFile, "TgVoipDex.java")
if (!javaVoipDirFile.exists()) {
javaVoipDirFile.mkdirs()
}
def assetsDirFile = new File(buildDir, "intermediates/merged_assets/${variant.name}/out")
if (!assetsDirFile.exists()) {
assetsDirFile.mkdirs()
}
def tgVoipDexFile = new File(assetsDirFile, tgVoipDexFileName)
def classes = tgVoipDir.list(new FilenameFilter() {
@Override
boolean accept(File dir, String name) {
// handle inner and anonymous classes
return tgVoipDexClasses.any { name == "${it}.class" || name.startsWith("${it}\$") && name.endsWith(".class") }
}
}).collect { "${tgVoipDexClassesPath}/${it}" }
// 1. create libtgvoip.dex
exec {
workingDir classesDir
commandLine([dxUtilPath, "--dex", "--output=${tgVoipDexFile}"] + classes)
}
// 2. remove classes from the main dex
project.delete classes.collect { "${classesDir}/${it}" }
// 3. insert checksum of libtgvoip.dex into TgVoipDex.java
def digest = MessageDigest.getInstance("SHA1")
def fileInputStream = tgVoipDexFile.newInputStream()
def buffer = new byte[4096]
def len
while ((len = fileInputStream.read(buffer)) > 0) {
digest.update(buffer, 0, len)
}
def dexChecksum = new String(Base64.getEncoder().encode(digest.digest())).trim()
tgVoipDexJavaFile.write(new String(new File(sourceDir, "${tgVoipDexClassesPath}/TgVoipDex.java").readBytes()).replace("\$CHECKSUM\$", dexChecksum))
exec {
commandLine([findJavac(), "-d", classesDir, tgVoipDexJavaFile.absolutePath])
}
}
}
tasks.findByName("compile${variant.name.capitalize()}JavaWithJavac").finalizedBy(assembleTgVoipDexTaskName)
tasks.findByName("${assembleTgVoipDexTaskName}").mustRunAfter tasks.findByName("merge${variant.name.capitalize()}Assets")
2016-03-16 13:26:32 +01:00
}
2019-03-03 21:40:48 +01:00
variantFilter { variant ->
def names = variant.flavors*.name
2019-05-14 14:08:05 +02:00
if (variant.buildType.name != "release" && !names.contains("afat")) {
2019-03-03 21:40:48 +01:00
setIgnore(true)
}
}
2013-10-25 17:19:00 +02:00
defaultConfig {
2017-07-23 15:43:02 +02:00
minSdkVersion 16
2019-12-08 10:55:30 +01:00
targetSdkVersion 28
2020-06-10 07:05:48 +02:00
versionName "6.2.0.1"
2018-07-30 04:07:02 +02:00
2019-05-14 14:08:05 +02:00
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
2016-10-11 13:57:01 +02:00
externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8", "LOCAL_ARM_NEON:=false"
2018-07-30 04:07:02 +02:00
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
2016-10-11 13:57:01 +02:00
}
}
2013-10-25 17:19:00 +02:00
}
bundle {
language {
enableSplit = false
}
}
2013-10-25 17:19:00 +02:00
}
2016-04-22 15:49:00 +02:00
2020-03-30 14:00:09 +02:00
private static File findJavaHome() {
String javaPath = System.getProperty("java.home")
if (javaPath != null) {
File javaBase = new File(javaPath)
if (javaBase.exists()) {
if (javaBase.getName().equalsIgnoreCase("jre") && new File(javaBase.getParentFile(), "bin/java").exists()) {
return javaBase.getParentFile()
} else {
return javaBase
}
} else {
return null
}
} else {
return null
}
}
private static File findJavac() {
File javaHome = findJavaHome()
if (javaHome != null) {
if (OperatingSystem.current().isWindows()) {
return new File(javaHome.getParent(), "bin/javac.exe")
} else {
return new File(javaHome, "bin/javac")
}
2020-03-30 14:00:09 +02:00
} else {
return null
}
}