difuse-phone-android/app/build.gradle

286 lines
11 KiB
Groovy
Raw Normal View History

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'org.jlleitschuh.gradle.ktlint' version '11.3.1'
2023-02-07 15:09:28 +00:00
id 'org.jetbrains.kotlin.android'
}
2021-02-10 15:52:11 +00:00
def appVersionName = "1.0.1"
def appVersionCode = 52001
2021-11-23 13:23:27 +00:00
2024-02-27 09:28:25 +00:00
def packageName = "org.difusephone"
2018-11-15 12:06:12 +00:00
def firebaseAvailable = new File(projectDir.absolutePath +'/google-services.json').exists()
def crashlyticsAvailable = new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
2021-02-10 15:52:11 +00:00
def extractNativeLibs = false
if (firebaseAvailable) {
apply plugin: 'com.google.gms.google-services'
}
2021-02-03 14:27:55 +00:00
def gitBranch = new ByteArrayOutputStream()
2019-05-16 10:18:57 +00:00
task getGitVersion() {
2021-11-23 13:23:27 +00:00
def gitVersion = appVersionName
2019-05-16 10:18:57 +00:00
def gitVersionStream = new ByteArrayOutputStream()
def gitCommitsCount = new ByteArrayOutputStream()
def gitCommitHash = new ByteArrayOutputStream()
2019-05-16 10:18:57 +00:00
2019-05-17 11:53:04 +00:00
try {
exec {
executable "git" args "describe", "--abbrev=0"
2019-05-17 11:53:04 +00:00
standardOutput = gitVersionStream
}
exec {
executable "git" args "rev-list", gitVersionStream.toString().trim() + "..HEAD", "--count"
standardOutput = gitCommitsCount
}
exec {
executable "git" args "rev-parse", "--short", "HEAD"
standardOutput = gitCommitHash
}
2021-02-03 14:27:55 +00:00
exec {
executable "git" args "name-rev", "--name-only", "HEAD"
standardOutput = gitBranch
}
if (gitCommitsCount.toString().toInteger() == 0) {
gitVersion = gitVersionStream.toString().trim()
} else {
gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim()
}
2021-11-23 13:23:27 +00:00
println("Git version: " + gitVersion + " (" + appVersionCode + ")")
} catch (ignored) {
2021-11-23 13:23:27 +00:00
println("Git not found, using " + gitVersion + " (" + appVersionCode + ")")
2019-05-16 10:18:57 +00:00
}
project.version = gitVersion
}
configurations {
2021-01-28 09:35:02 +00:00
customImplementation.extendsFrom implementation
}
2021-01-08 10:49:58 +00:00
task linphoneSdkSource() {
doLast {
configurations.customImplementation.getIncoming().each {
2021-01-08 10:49:58 +00:00
it.getResolutionResult().allComponents.each {
if (it.id.getDisplayName().contains("linphone-sdk-android")) {
println 'Linphone SDK used is ' + it.moduleVersion.version + ' from ' + it.properties["repositoryName"]
}
}
}
}
}
2019-05-16 10:18:57 +00:00
project.tasks['preBuild'].dependsOn 'getGitVersion'
project.tasks['preBuild'].dependsOn 'linphoneSdkSource'
2019-05-16 10:18:57 +00:00
2018-11-15 12:06:12 +00:00
android {
compileOptions {
sourceCompatibility = 17
targetCompatibility = 17
}
compileSdkVersion 34
2018-11-15 12:06:12 +00:00
defaultConfig {
2020-06-24 08:09:12 +00:00
minSdkVersion 23
targetSdkVersion 34
2021-11-23 13:23:27 +00:00
versionCode appVersionCode
2019-05-16 10:18:57 +00:00
versionName "${project.version}"
applicationId packageName
2018-11-15 12:06:12 +00:00
}
2018-11-19 10:59:12 +00:00
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "difuse-phone-android-${variant.buildType.name}-${project.version}.apk"
2018-11-19 10:59:12 +00:00
}
var enableFirebaseService = "false"
if (firebaseAvailable) {
enableFirebaseService = "true"
}
// See https://developer.android.com/studio/releases/gradle-plugin#3-6-0-behavior for why extractNativeLibs is set to true in debug flavor
2021-11-16 12:52:46 +00:00
if (variant.buildType.name == "release" || variant.buildType.name == "releaseWithCrashlytics") {
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address",
linphone_file_provider: packageName + ".fileprovider",
appLabel: "@string/app_name",
firebaseServiceEnabled: enableFirebaseService]
} else {
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address",
linphone_file_provider: packageName + ".debug.fileprovider",
appLabel: "@string/app_name_debug",
firebaseServiceEnabled: enableFirebaseService]
extractNativeLibs = true
}
2018-11-19 10:59:12 +00:00
}
2018-11-19 09:42:14 +00:00
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
2018-11-15 12:06:12 +00:00
signingConfigs {
release {
2018-11-19 09:42:14 +00:00
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
2018-11-15 12:06:12 +00:00
}
}
2018-11-15 12:06:12 +00:00
buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
2018-11-19 09:27:25 +00:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2021-02-03 14:27:55 +00:00
resValue "string", "linphone_app_branch", gitBranch.toString().trim()
resValue "string", "sync_account_type", packageName + ".sync"
resValue "string", "file_provider", packageName + ".fileprovider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address"
if (!firebaseAvailable) {
resValue "string", "gcm_defaultSenderId", "none"
}
2021-02-25 08:24:57 +00:00
resValue "bool", "crashlytics_enabled", "false"
2018-11-15 12:06:12 +00:00
}
2020-03-29 12:14:04 +00:00
releaseWithCrashlytics {
initWith release
resValue "bool", "crashlytics_enabled", crashlyticsAvailable.toString()
if (crashlyticsAvailable) {
apply plugin: 'com.google.firebase.crashlytics'
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs-debug/').toString()
}
}
}
2018-11-15 12:06:12 +00:00
debug {
applicationIdSuffix ".debug"
debuggable true
jniDebuggable true
2021-02-03 14:27:55 +00:00
resValue "string", "linphone_app_branch", gitBranch.toString().trim()
resValue "string", "sync_account_type", packageName + ".sync"
resValue "string", "file_provider", packageName + ".debug.fileprovider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address"
resValue "bool", "crashlytics_enabled", crashlyticsAvailable.toString()
if (!firebaseAvailable) {
resValue "string", "gcm_defaultSenderId", "none"
}
2021-02-10 15:52:11 +00:00
if (crashlyticsAvailable) {
apply plugin: 'com.google.firebase.crashlytics'
2021-02-10 15:52:11 +00:00
firebaseCrashlytics {
2023-01-16 14:59:28 +00:00
nativeSymbolUploadEnabled false
2021-02-10 15:52:11 +00:00
}
}
2018-11-15 12:06:12 +00:00
}
}
2020-05-29 07:58:37 +00:00
buildFeatures {
dataBinding = true
2018-11-15 12:06:12 +00:00
}
2022-05-12 09:42:16 +00:00
namespace 'org.linphone'
packagingOptions {
jniLibs {
useLegacyPackaging extractNativeLibs
}
}
2020-03-29 12:14:04 +00:00
}
2018-11-19 10:59:12 +00:00
dependencies {
2020-03-29 12:14:04 +00:00
implementation fileTree(dir: 'libs', include: ['*.jar'])
2023-02-10 09:37:59 +00:00
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-splashscreen:1.0.1'
2023-09-11 14:32:01 +00:00
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
2022-06-28 09:40:27 +00:00
implementation 'androidx.media:media:1.6.0'
2023-05-05 08:44:52 +00:00
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha06"
implementation "androidx.window:window:1.2.0"
def emoji_version = "1.4.0"
2023-05-25 08:46:00 +00:00
implementation "androidx.emoji2:emoji2:$emoji_version"
implementation "androidx.emoji2:emoji2-emojipicker:$emoji_version"
def nav_version = "2.7.5"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
2022-01-27 08:58:08 +00:00
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.drawerlayout:drawerlayout:1.2.0'
2022-05-13 14:57:48 +00:00
// https://github.com/material-components/material-components-android/blob/master/LICENSE Apache v2.0
implementation 'com.google.android.material:material:1.10.0'
2022-04-20 07:33:22 +00:00
// https://github.com/google/flexbox-layout/blob/main/LICENSE Apache v2.0
implementation 'com.google.android.flexbox:flexbox:3.0.0'
2020-10-15 08:22:06 +00:00
2022-04-20 10:56:31 +00:00
// https://github.com/coil-kt/coil/blob/main/LICENSE.txt Apache v2.0
2023-05-25 08:46:00 +00:00
def coil_version = "2.4.0"
2022-04-20 10:56:31 +00:00
implementation("io.coil-kt:coil:$coil_version")
implementation("io.coil-kt:coil-gif:$coil_version")
implementation("io.coil-kt:coil-svg:$coil_version")
implementation("io.coil-kt:coil-video:$coil_version")
2020-03-29 12:14:04 +00:00
2022-04-20 07:33:22 +00:00
// https://github.com/Baseflow/PhotoView/blob/master/LICENSE Apache v2.0
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation platform('com.google.firebase:firebase-bom:32.5.0')
if (crashlyticsAvailable) {
debugImplementation 'com.google.firebase:firebase-crashlytics-ndk'
releaseWithCrashlyticsImplementation 'com.google.firebase:firebase-crashlytics-ndk'
releaseCompileOnly 'com.google.firebase:firebase-crashlytics-ndk'
2021-02-25 08:24:57 +00:00
} else {
compileOnly 'com.google.firebase:firebase-crashlytics-ndk'
2021-02-10 15:52:11 +00:00
}
if (firebaseAvailable) {
2021-02-10 15:52:11 +00:00
implementation 'com.google.firebase:firebase-messaging'
}
2020-03-29 12:14:04 +00:00
implementation 'org.linphone:linphone-sdk-android:5.4+'
2020-09-09 13:05:38 +00:00
// Only enable leak canary prior to release
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
2018-11-24 08:46:31 +00:00
}
2020-03-29 12:14:04 +00:00
task generateContactsXml(type: Copy) {
from 'contacts.xml'
into "src/main/res/xml/"
outputs.upToDateWhen { file('src/main/res/xml/contacts.xml').exists() }
filter {
line -> line
.replaceAll('%%AUTO_GENERATED%%', 'This file has been automatically generated, do not edit or commit !')
.replaceAll('%%PACKAGE_NAME%%', packageName)
}
}
project.tasks['preBuild'].dependsOn 'generateContactsXml'
2020-03-29 12:14:04 +00:00
ktlint {
android = true
ignoreFailures = true
}
2020-03-29 12:14:04 +00:00
project.tasks['preBuild'].dependsOn 'ktlintFormat'
if (crashlyticsAvailable) {
afterEvaluate {
assembleReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
packageReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
}
}