difuse-phone-android/app/build.gradle

197 lines
6.7 KiB
Groovy
Raw Normal View History

2018-11-15 12:06:12 +00:00
apply plugin: 'com.android.application'
2020-03-29 12:14:04 +00:00
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "org.jlleitschuh.gradle.ktlint"
static def getPackageName() {
2018-11-15 12:06:12 +00:00
return "org.linphone"
}
static def firebaseEnabled() {
2018-11-24 08:46:31 +00:00
File googleFile = new File('app/google-services.json')
2018-11-15 12:06:12 +00:00
return googleFile.exists()
}
2019-05-16 10:18:57 +00:00
task getGitVersion() {
2020-06-24 09:36:07 +00:00
def gitVersion = "5.0.0"
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
}
if (gitCommitsCount.toString().toInteger() == 0) {
gitVersion = gitVersionStream.toString().trim()
} else {
gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim()
}
2019-05-16 10:18:57 +00:00
println("Git version: " + gitVersion)
} catch (ignored) {
2019-05-16 10:18:57 +00:00
println("Git not found")
}
project.version = gitVersion
}
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 {
compileSdkVersion 29
buildToolsVersion "29.0.3"
2018-11-15 12:06:12 +00:00
defaultConfig {
2020-06-24 08:09:12 +00:00
minSdkVersion 23
targetSdkVersion 29
2020-06-24 09:36:07 +00:00
versionCode 4999
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
}
// https://developer.android.com/studio/releases/gradle-plugin#3-6-0-behavior for extractNativeLibs
if (variant.buildType.name == "release") {
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"]
} 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"]
}
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'
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"
}
2018-11-15 12:06:12 +00:00
}
2020-03-29 12:14:04 +00:00
2018-11-15 12:06:12 +00:00
debug {
applicationIdSuffix ".debug"
debuggable true
jniDebuggable true
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"
if (!firebaseEnabled()) {
resValue "string", "gcm_defaultSenderId", "none"
}
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"
}
2020-03-29 12:14:04 +00:00
}
2018-11-19 10:59:12 +00:00
2020-03-29 12:14:04 +00:00
repositories {
maven {
url file(LinphoneSdkBuildDir + '/maven_repository/')
2018-11-15 12:06:12 +00:00
}
2020-03-29 12:14:04 +00:00
maven {
2020-03-29 12:14:04 +00:00
url "https://linphone.org/maven_repository"
}
}
dependencies {
2020-03-29 12:14:04 +00:00
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
2020-03-29 12:14:04 +00:00
implementation "androidx.media:media:1.1.0"
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'androidx.core:core-ktx:1.3.1'
2020-06-25 09:13:07 +00:00
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
2020-03-29 12:14:04 +00:00
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android:flexbox:2.0.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.google.android.material:material:1.2.0'
2020-03-29 12:14:04 +00:00
if (firebaseEnabled()) {
implementation 'com.google.firebase:firebase-messaging:19.0.1'
}
2020-03-29 12:14:04 +00:00
2020-06-24 09:36:07 +00:00
implementation 'org.linphone:linphone-sdk-android:4.5+'
2018-11-24 08:46:31 +00:00
}
2020-03-29 12:14:04 +00:00
2018-11-24 08:46:31 +00:00
if (firebaseEnabled()) {
apply plugin: 'com.google.gms.google-services'
2018-11-26 10:18:15 +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
2020-06-24 09:36:07 +00:00
project.tasks['preBuild'].dependsOn 'ktlintFormat'