Minor changes in build.gradle

This commit is contained in:
Sylvain Berfini 2018-02-02 16:04:30 +01:00
parent d3baa8de36
commit d668a8f8ab

View file

@ -2,58 +2,59 @@
buildDir = 'bin' buildDir = 'bin'
def getPackageName() { def getPackageName() {
return "org.linphone" return "org.linphone"
} }
def firebaseEnable() { def firebaseEnable() {
File googleFile = new File('google-services.json') File googleFile = new File('google-services.json')
return googleFile.exists() return googleFile.exists()
} }
buildscript { buildscript {
File googleFile = new File('google-services.json') File googleFile = new File('google-services.json')
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:2.3.3'
if (googleFile.exists()) { if (googleFile.exists()) {
classpath 'com.google.gms:google-services:3.+' classpath 'com.google.gms:google-services:3.+'
}
classpath 'com.google.gms:google-services:3.1.0'
} }
}
} }
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
google() google()
} }
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
dependencies { dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:+') { androidTestCompile('com.android.support.test.espresso:espresso-core:+') {
exclude module: 'support-annotations' exclude module: 'support-annotations'
} }
androidTestCompile 'com.jayway.android.robotium:robotium-solo:+' androidTestCompile 'com.jayway.android.robotium:robotium-solo:+'
androidTestCompile 'junit:junit:+' androidTestCompile 'junit:junit:+'
compile 'org.apache.commons:commons-compress:+' compile 'org.apache.commons:commons-compress:+'
if (firebaseEnable()) { if (firebaseEnable()) {
compile 'com.google.firebase:firebase-messaging:11.+' compile 'com.google.firebase:firebase-messaging:11.+'
} else { } else {
compile fileTree(include: 'gcm.jar', dir: 'libs') compile fileTree(include: 'gcm.jar', dir: 'libs')
compile 'com.android.support:support-v4:+' compile 'com.android.support:support-v4:+'
} }
} }
if (firebaseEnable()) { if (firebaseEnable()) {
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
} }
//// Submodule Dir ///// //// Submodule Dir /////
@ -64,11 +65,11 @@ def submoduleDir = ['submodules/mediastreamer2/java/src']
def excludeFiles = [] def excludeFiles = []
// Exclude firebase file if not enable // Exclude firebase file if not enable
if (!firebaseEnable()) { if (!firebaseEnable()) {
excludeFiles.add('**/Firebase*') excludeFiles.add('**/Firebase*')
println '[Push Notification] Firebase disabled' println '[Push Notification] Firebase disabled'
} else { } else {
excludeFiles.add('**/gcm*') excludeFiles.add('**/gcm*')
println '[Push Notification] Firebase enabled' println '[Push Notification] Firebase enabled'
} }
excludeFiles.add('**/mediastream/MediastreamerActivity.java') excludeFiles.add('**/mediastream/MediastreamerActivity.java')
excludeFiles.add('src/android/org/linphone/tutorials/*.java') excludeFiles.add('src/android/org/linphone/tutorials/*.java')
@ -82,115 +83,117 @@ excludePackage.add('**/LICENSE.txt')
///////////////////////// /////////////////////////
android { android {
defaultConfig { defaultConfig {
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion "26.0.1" buildToolsVersion "26.0.1"
applicationId getPackageName() applicationId getPackageName()
multiDexEnabled true multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
disable 'MissingTranslation', 'UnusedResources'
}
// Signing
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
} }
} lintOptions {
buildTypes { checkReleaseBuilds false
release { // Or, if you prefer, you can continue to check for errors in release builds,
signingConfig signingConfigs.release // but continue the build even when errors are found:
abortOnError false
disable 'MissingTranslation', 'UnusedResources'
} }
packaged { // Signing
initWith release signingConfigs {
signingConfig null release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
} }
} buildTypes {
sourceSets { release {
main { signingConfig signingConfigs.release
manifest.srcFile 'AndroidManifest.xml' }
def srcDirs = submoduleDir packaged {
srcDirs.addAll(['src/linphone-wrapper', 'src/android']) initWith release
java.srcDirs = srcDirs signingConfig null
resources.srcDirs = srcDirs }
aidl.srcDirs = srcDirs }
renderscript.srcDirs = srcDirs sourceSets {
res.srcDirs = ['res'] main {
assets.srcDirs = ['assets'] manifest.srcFile 'AndroidManifest.xml'
jniLibs.srcDirs = ['libs'] def srcDirs = submoduleDir
java.excludes = excludeFiles srcDirs.addAll(['src/linphone-wrapper', 'src/android'])
java.srcDirs = srcDirs
resources.srcDirs = srcDirs
aidl.srcDirs = srcDirs
renderscript.srcDirs = srcDirs
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
java.excludes = excludeFiles
// Exclude some useless files // Exclude some useless files
packagingOptions { packagingOptions {
excludes = excludePackage excludes = excludePackage
} }
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
} }
sourceSets {
androidTest {
manifest.srcFile 'AndroidManifest.xml'
def srcDirs = submoduleDir
srcDirs.addAll(['src/android',
'src/androidTest'])
java.srcDirs = srcDirs
resources.srcDirs = srcDirs
aidl.srcDirs = srcDirs
renderscript.srcDirs = srcDirs
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
java.excludes = excludeFiles
debug.setRoot('build-types/debug') // Exclude some useless files
release.setRoot('build-types/release') packagingOptions {
} excludes = excludePackage
sourceSets { }
androidTest { }
manifest.srcFile 'AndroidManifest.xml'
def srcDirs = submoduleDir
srcDirs.addAll(['src/android',
'src/androidTest'])
java.srcDirs = srcDirs
resources.srcDirs = srcDirs
aidl.srcDirs = srcDirs
renderscript.srcDirs = srcDirs
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
java.excludes = excludeFiles
// Exclude some useless files debug.setRoot('build-types/debug')
packagingOptions { release.setRoot('build-types/release')
excludes = excludePackage }
} packagingOptions {
pickFirst 'META-INF/NOTICE'
pickFirst 'META-INF/LICENSE'
} }
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
pickFirst 'META-INF/NOTICE'
pickFirst 'META-INF/LICENSE'
}
} }
// Grant permissions // Grant permissions
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
def applicationId = getPackageName() def applicationId = getPackageName()
def adb = android.getAdbExecutable().toString() def adb = android.getAdbExecutable().toString()
def variantName = variant.name.capitalize() def variantName = variant.name.capitalize()
def grantPermissionTask = tasks.create("grant${variantName}Permissions").doLast({ def grantPermissionTask = tasks.create("grant${variantName}Permissions").doLast({
"${adb} devices".execute().text.eachLine { "${adb} devices".execute().text.eachLine {
"${adb} shell pm grant ${applicationId} android.permission.RECORD_AUDIO".execute() "${adb} shell pm grant ${applicationId} android.permission.RECORD_AUDIO".execute()
"${adb} shell pm grant ${applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute() "${adb} shell pm grant ${applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute()
"${adb} shell pm grant ${applicationId} android.permission.CAMERA".execute() "${adb} shell pm grant ${applicationId} android.permission.CAMERA".execute()
"${adb} shell pm grant ${applicationId} android.permission.READ_PHONE_STATE".execute() "${adb} shell pm grant ${applicationId} android.permission.READ_PHONE_STATE".execute()
"${adb} shell pm grant ${applicationId} android.permission.READ_CONTACTS".execute() "${adb} shell pm grant ${applicationId} android.permission.READ_CONTACTS".execute()
"${adb} shell pm grant ${applicationId} android.permission.WRITE_CONTACTS".execute() "${adb} shell pm grant ${applicationId} android.permission.WRITE_CONTACTS".execute()
} }
}) })
} }
task runApplication { task runApplication {
doLast { doLast {
def result = exec { def result = exec {
executable = android.getAdbExecutable().toString() executable = android.getAdbExecutable().toString()
ignoreExitValue true ignoreExitValue true
args = ['shell', 'monkey', '-p', getPackageName(), '-c', 'android.intent.category.LAUNCHER', '1'] args = ['shell', 'monkey', '-p', getPackageName(), '-c', 'android.intent.category.LAUNCHER', '1']
}
} }
}
} }
apply plugin: 'com.google.gms.google-services'