apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: "org.jlleitschuh.gradle.ktlint" static def getPackageName() { return "org.linphone" } static def firebaseEnabled() { File googleFile = new File('app/google-services.json') return googleFile.exists() } task getGitVersion() { def gitVersion = "5.0" def gitVersionStream = new ByteArrayOutputStream() def gitCommitsCount = new ByteArrayOutputStream() def gitCommitHash = new ByteArrayOutputStream() try { exec { executable "git" args "describe", "--abbrev=0" 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() } println("Git version: " + gitVersion) } catch (Exception e) { println("Git not found") } project.version = gitVersion } project.tasks['preBuild'].dependsOn 'getGitVersion' project.tasks['preBuild'].dependsOn 'linphoneSdkSource' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { minSdkVersion 23 targetSdkVersion 29 versionCode 4300 versionName "${project.version}" applicationId getPackageName() } applicationVariants.all { variant -> variant.outputs.all { outputFileName = "linphone-android-${variant.buildType.name}-${project.version}.apk" } // 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"] } else { variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address", linphone_file_provider: getPackageName() + ".debug.fileprovider"] } } def keystorePropertiesFile = rootProject.file("keystore.properties") def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) signingConfigs { release { storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] } } buildTypes { release { minifyEnabled true signingConfig signingConfigs.release proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' resValue "string", "sync_account_type", getPackageName() + ".sync" 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" } } debug { applicationIdSuffix ".debug" debuggable true jniDebuggable true resValue "string", "sync_account_type", getPackageName() + ".sync" 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" } } } dataBinding { enabled = true } } repositories { maven { url file(LinphoneSdkBuildDir + '/maven_repository/') } /*maven { url "https://linphone.org/maven_repository" }*/ } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.1.0' implementation "androidx.media:media:1.1.0" implementation 'androidx.fragment:fragment-ktx:1.2.3' implementation 'androidx.core:core-ktx:1.2.0' implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' implementation 'androidx.navigation:navigation-ui-ktx:2.2.1' 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' if (firebaseEnabled()) { implementation 'com.google.firebase:firebase-messaging:19.0.1' } implementation 'org.linphone:linphone-sdk-android:4.4+' } if (firebaseEnabled()) { apply plugin: 'com.google.gms.google-services' } task generateContactsXml(type: Copy) { from 'contacts.xml' into "src/main/res/xml/" 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' ktlint { android = true ignoreFailures = true } project.tasks['preBuild'].dependsOn 'ktlintFormat'