kiwix-android/app/build.gradle

265 lines
8.1 KiB
Groovy

import groovy.json.JsonSlurper
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
classpath 'com.testdroid:gradle:1.5.0'
classpath 'org.apache.httpcomponents:httpclient-android:4.3.3'
}
}
//apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'checkstyle'
apply plugin: 'testdroid'
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile 'com.google.dagger:dagger:2.0.2'
compile project(":kiwixlib")
apt "com.google.dagger:dagger-compiler:2.0.2"
androidTestApt "com.google.dagger:dagger-compiler:2.0.2"
compile 'com.yahoo.squidb:squidb:2.0.0'
compile 'com.yahoo.squidb:squidb-annotations:2.0.0'
apt 'com.yahoo.squidb:squidb-processor:2.0.0'
compile 'commons-io:commons-io:2.5'
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.6.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile('com.squareup.retrofit2:converter-simplexml:2.1.0') {
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.3'
testCompile "org.mockito:mockito-core:2.7.22"
androidTestCompile "org.mockito:mockito-android:2.7.22"
compile 'eu.mhutti1.utils.storage:android-storage-devices:0.5.0'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile group: 'com.google.guava', name: 'guava', version: '20.0'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
compile 'com.android.support.test:runner:0.5'
compile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}}
// Set custom app import directory
def map = [:]
def custom = new File("app/src")
if (project.hasProperty('customDir')) {
custom = file(project.property('customDir'))
}
// Set up flavours for each custom app in the directory
custom.eachFile() { file->
def fileName = file.getName()
if( fileName.contains("test") || fileName == "main" || fileName.contains("Test")) {
return
}
map.put(fileName, file.getAbsolutePath())
}
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
lintOptions {
abortOnError true
// Hardcoded strings in xml
error 'HardcodedText'
// Hardcoded strings in setText
error 'SetTextI18n'
// Strings.xml issues
warning 'ExtraTranslation'
warning 'MissingTranslation'
// Warnings
warning 'InvalidPackage'
warning 'StringFormatInvalid'
}
buildTypes {
debug {
// True breaks local variables being shown in breakpoints
testCoverageEnabled false
// Needed for instrumentation tests on Pre 5.0
multiDexKeepProguard file('multidex-instrumentation-config.pro')
}
coverage {
initWith debug
testCoverageEnabled true
}
release {
}
}
productFlavors {
// Vanilla Kiwix app
kiwix {
println "Building Kiwix"
// Set vanilla config
buildConfigField "boolean", "IS_CUSTOM_APP", "false"
buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "false"
buildConfigField "String", "ZIM_FILE_NAME", "\"\""
buildConfigField "long", "ZIM_FILE_SIZE", "0"
buildConfigField "int", "CONTENT_VERSION_CODE", "0"
buildConfigField "String", "ENFORCED_LANG", "\"\""
resValue "string", "app_name", "Kiwix"
resValue "string", "app_search_string", "Search Kiwix"
}
// Custom apps built from a json file, zim file and icon set
map.each { name, directory ->
"$name" {
println "Building Custom"
def jsonFile = ""
if (project.hasProperty('jsonFile')) {
// Read json file from properties e.g command line
jsonFile = file(project.property('jsonFile'))
} else {
// If no file provided use the test file
jsonFile = file(directory + '/test.json')
}
def parsedJson = new JsonSlurper().parseText(jsonFile.text)
def File zimfile = new File(parsedJson.zim_file)
if (parsedJson.embed_zim) {
// Place content in each lib directory for embeded zims
file("../kiwixlib/src/main/jniLibs").eachDir() { folder ->
copy {
from parsedJson.zim_file
into file(directory + "/jniLibs/" + folder.name)
rename { String filename -> "libcontent.so" }
}
}
parsedJson.zim_file = "libcontent.so"
}
// Set custom config from json
applicationId "$parsedJson.package"
buildConfigField "boolean", "IS_CUSTOM_APP", "true"
buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "$parsedJson.embed_zim"
def filename = ""
if (parsedJson.zim_file.lastIndexOf('/') >= 0) {
filename = parsedJson.zim_file.substring(parsedJson.zim_file.lastIndexOf('/') + 1)
} else {
filename = parsedJson.zim_file
}
buildConfigField "String", "ZIM_FILE_NAME", "\"$filename\""
long length = zimfile.length()
buildConfigField "long", "ZIM_FILE_SIZE", "$length"
if (parsedJson.content_version_code != null) {
buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.content_version_code"
} else {
buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.version_code"
}
buildConfigField "String", "ENFORCED_LANG", "\"$parsedJson.enforced_lang\""
resValue "string", "app_name", "$parsedJson.app_name"
resValue "string", "app_search_string", 'Search ' + "$parsedJson.app_name"
}
}
}
sourceSets {
map.each { name, directory ->
"$name" {
setRoot directory
}
}
}
compileOptions {
encoding = "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
/* Add back once proguard is configured
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}*/
}
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
testdroid {
username System.getenv('TESTDROID_USERNAME')
password System.getenv('TESTDROID_PASSWORD')
deviceGroup 'Kiwix'
projectName "Kiwix"
fullRunConfig {
instrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
}
}