difuse-phone-android/app/build.gradle

288 lines
11 KiB
Groovy
Raw Normal View History

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'org.jlleitschuh.gradle.ktlint'
}
2021-02-10 15:52:11 +00:00
2022-02-09 14:09:03 +00:00
def appVersionName = "4.7.0"
// Uncomment for 4.7.0 release
// def appVersionCode = 40700 // 4.07.00
def appVersionCode = 40694 // 4.06.94
2021-11-23 13:23:27 +00:00
static def getPackageName() {
2018-11-15 12:06:12 +00:00
return "org.linphone"
}
def firebaseEnabled = new File(projectDir.absolutePath +'/google-services.json').exists()
def crashlyticsEnabled = new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
2018-11-15 12:06:12 +00:00
2021-02-10 15:52:11 +00:00
if (firebaseEnabled) {
apply plugin: 'com.google.gms.google-services'
}
if (crashlyticsEnabled) {
2021-02-10 15:52:11 +00:00
apply plugin: 'com.google.firebase.crashlytics'
}
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 {
2022-06-09 12:02:03 +00:00
compileSdkVersion 33
buildToolsVersion '33.0.0'
2018-11-15 12:06:12 +00:00
defaultConfig {
2020-06-24 08:09:12 +00:00
minSdkVersion 23
2022-06-09 12:02:03 +00:00
targetSdkVersion 33
2021-11-23 13:23:27 +00:00
versionCode appVersionCode
2019-05-16 10:18:57 +00:00
versionName "${project.version}"
2018-11-15 12:06:12 +00:00
applicationId getPackageName()
}
2018-11-19 10:59:12 +00:00
applicationVariants.all { variant ->
variant.outputs.all {
2019-05-16 10:18:57 +00:00
outputFileName = "linphone-android-${variant.buildType.name}-${project.version}.apk"
2018-11-19 10:59:12 +00:00
}
var enableFirebaseService = "false"
if (firebaseEnabled) {
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." + getPackageName() + ".provider.sip_address",
linphone_file_provider: getPackageName() + ".fileprovider",
appLabel: "@string/app_name",
firebaseServiceEnabled: enableFirebaseService,
extractNativeLibs: "false"]
} else {
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address",
linphone_file_provider: getPackageName() + ".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", getPackageName() + ".sync"
2020-03-29 12:14:04 +00:00
resValue "string", "file_provider", getPackageName() + ".fileprovider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
if (!firebaseEnabled) {
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", crashlyticsEnabled.toString()
2021-11-16 12:29:02 +00:00
if (crashlyticsEnabled) {
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", getPackageName() + ".sync"
2020-03-29 12:14:04 +00:00
resValue "string", "file_provider", getPackageName() + ".debug.fileprovider"
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
2021-11-16 12:29:02 +00:00
resValue "bool", "crashlytics_enabled", crashlyticsEnabled.toString()
if (!firebaseEnabled) {
resValue "string", "gcm_defaultSenderId", "none"
}
2021-02-10 15:52:11 +00:00
if (crashlyticsEnabled) {
2021-02-10 15:52:11 +00:00
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs-debug/').toString()
}
}
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
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
2022-05-12 09:42:16 +00:00
namespace 'org.linphone'
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'])
implementation 'androidx.appcompat:appcompat:1.6.0-beta01'
implementation 'androidx.core:core-ktx:1.9.0-beta01'
implementation 'androidx.core:core-splashscreen:1.0.0'
implementation 'androidx.fragment:fragment-ktx:1.5.2'
2022-07-28 10:28:07 +00:00
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
2022-06-28 09:40:27 +00:00
implementation 'androidx.media:media:1.6.0'
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha03"
implementation "androidx.window:window:1.0.0"
2022-07-28 10:28:07 +00:00
def nav_version = "2.5.1"
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"
2022-07-15 15:29:07 +00:00
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha03'
implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation 'androidx.recyclerview:recyclerview:1.3.0-beta02'
2022-05-13 14:57:48 +00:00
// https://github.com/material-components/material-components-android/blob/master/LICENSE Apache v2.0
2022-06-09 12:02:03 +00:00
implementation 'com.google.android.material:material:1.6.1'
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-06-28 09:40:27 +00:00
implementation 'androidx.emoji:emoji:1.1.0'
implementation 'androidx.emoji:emoji-bundled:1.1.0'
2022-04-20 10:56:31 +00:00
// https://github.com/coil-kt/coil/blob/main/LICENSE.txt Apache v2.0
2022-07-15 15:29:07 +00:00
def coil_version = "2.1.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'
2022-07-28 10:28:07 +00:00
implementation platform('com.google.firebase:firebase-bom:30.3.1')
if (crashlyticsEnabled) {
2021-02-10 15:52:11 +00:00
implementation '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 (firebaseEnabled) {
2021-02-10 15:52:11 +00:00
implementation 'com.google.firebase:firebase-messaging'
}
2020-03-29 12:14:04 +00:00
2021-09-15 09:44:23 +00:00
implementation 'org.linphone:linphone-sdk-android:5.2+'
2020-09-09 13:05:38 +00:00
// Only enable leak canary prior to release
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
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%%', getPackageName())
}
}
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 (crashlyticsEnabled) {
afterEvaluate {
assembleDebug.finalizedBy(uploadCrashlyticsSymbolFileDebug)
packageDebugBundle.finalizedBy(uploadCrashlyticsSymbolFileDebug)
assembleReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
packageReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
}
}