kiwix-android/app/build.gradle

244 lines
6.2 KiB
Groovy

import com.android.build.OutputFile
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
dependencies {
}
}
}
plugins {
id("com.android.application")
id("checkstyle")
id("com.github.triplet.play") version("2.4.1")
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco-android'
apply plugin: "org.jlleitschuh.gradle.ktlint"
def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') ?: "dev"
ext {
versionMajor = 3
versionMinor = 0
versionPatch = 3
}
private String generateVersionName() {
"${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
}
/*
* max version code: 21-0-0-00-00-00
* our template : UU-D-A-ZZ-YY-XX
* where:
* X = patch version
* Y = minor version
* Z = major version (+ 20 to distinguish from previous, non semantic, versions of the app)
* A = number representing ABI split
* D = number representing density split
* U = unused
*/
private Integer generateVersionCode() {
20 * 10000 +
(ext.versionMajor * 10000) +
(ext.versionMinor * 100) +
(ext.versionPatch)
}
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
archivesBaseName = "$buildNumber"
// 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"
versionCode generateVersionCode()
versionName generateVersionName()
}
aaptOptions {
cruncherEnabled true
}
lintOptions {
abortOnError true
checkAllWarnings true
warningsAsErrors true
ignore 'SyntheticAccessor',
//TODO stop ignoring below this
'MissingTranslation',
'CheckResult',
'LabelFor',
'DuplicateStrings',
'LogConditional'
warning 'UnknownNullness',
'SelectableText',
'IconDensities',
'SyntheticAccessor'
baseline file("lint-baseline.xml")
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
unitTests.returnDefaultValues = true
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
signingConfigs {
release {
storeFile file("../kiwix-android.keystore")
storePassword System.getenv("KEY_STORE_PASSWORD") ?: "000000"
keyAlias System.getenv("KEY_ALIAS") ?: "keystore"
keyPassword System.getenv("KEY_PASSWORD") ?: "000000"
}
}
buildTypes {
// Main build type for debugging
debug {
multiDexKeepProguard file("multidex-instrumentation-config.pro")
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
testCoverageEnabled true
}
// Release Type
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "true"
}
}
compileOptions {
encoding = "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
androidExtensions {
experimental = true
}
def abiCodes = ['arm64-v8a': 6, 'x86': 3, 'x86_64': 4, 'armeabi-v7a': 5]
def densityCodes = ['mdpi': 2, 'hdpi': 3, 'xhdpi': 4, 'xxhdpi': 5, 'xxxhdpi': 6]
splits {
abi {
enable true
reset()
include "x86", "x86_64", 'armeabi-v7a', "arm64-v8a"
universalApk true
}
density {
enable false
reset()
include "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def baseAbiVersionCode = abiCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
def baseDensityVersionCode = densityCodes.get(output.getFilter(OutputFile.DENSITY)) ?: 0
output.versionCodeOverride =
(baseDensityVersionCode * 10000000) +
(baseAbiVersionCode * 1000000) +
variant.versionCode
}
}
}
play {
enabled = true
serviceAccountCredentials = file("../google.json")
track = "alpha"
releaseStatus = "draft"
resolutionStrategy = "fail"
}
ktlint {
android = true
}
jacoco {
toolVersion = "0.8.3"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
apply from: "${rootDir}/team-props/git-hooks.gradle"
dependencies {
implementation project(":core")
implementation(Libs.appcompat)
androidTestImplementation(Libs.espresso_core)
androidTestImplementation(Libs.espresso_web)
androidTestImplementation(Libs.espresso_intents)
androidTestImplementation(Libs.barista) {
exclude group: "com.android.support.test.uiautomator"
}
androidTestImplementation(Libs.espresso_contrib)
androidTestImplementation(Libs.androidx_annotation)
androidTestImplementation(Libs.junit)
androidTestImplementation(Libs.androidx_test_runner)
androidTestImplementation(Libs.androidx_test_rules)
androidTestImplementation(Libs.androidx_test_core)
androidTestImplementation(Libs.mockwebserver)
androidTestUtil(Libs.orchestrator)
androidTestImplementation(Libs.mockito_android)
androidTestCompileOnly(Libs.javax_annotation_api)
implementation(Libs.dagger)
kaptAndroidTest(Libs.dagger_compiler)
androidTestImplementation(Libs.mockk_android)
androidTestImplementation(Libs.uiautomator)
androidTestImplementation(Libs.assertj_core)
androidTestImplementation(Libs.simple_xml) {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
}