UserLAnd/app/build.gradle

308 lines
11 KiB
Groovy

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'jacoco'
apply plugin: 'de.undercouch.download'
android {
compileSdkVersion 29
defaultConfig {
// Version code is generated as time since June 1, 2019. These allows for constantly
// sequential deployments to both production and beta tracks.
def vcode = (int)(((new Date().getTime()/1000) - 1559347200) / 10)
applicationId "tech.ula"
minSdkVersion 21
targetSdkVersion 29
versionCode vcode
versionName "2.6.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
vectorDrawables.useSupportLibrary = true
// Ignore Sentry packages that cause lint failure
lintOptions {
lintConfig file("$projectDir/src/main/resources/lint.xml")
}
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
}
signingConfigs {
beta {
storeFile project.file('../keystore.jks')
keyAlias System.getenv('ANDROID_KEY_ALIAS')
storePassword System.getenv('ANDROID_STORE_PASSWORD')
keyPassword System.getenv('ANDROID_KEY_PASSWORD')
}
release {
storeFile project.file('../keystore.jks')
keyAlias System.getenv('ANDROID_KEY_ALIAS')
storePassword System.getenv('ANDROID_STORE_PASSWORD')
keyPassword System.getenv('ANDROID_KEY_PASSWORD')
}
}
buildTypes {
debug {
debuggable true
minifyEnabled false
testCoverageEnabled true
}
beta {
versionNameSuffix "-beta-$defaultConfig.versionCode"
debuggable false
minifyEnabled false
signingConfig signingConfigs.beta
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
debuggable false
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
// Enable this and run lintVitalRelease task to check missing translations.
lintOptions {
disable 'MissingTranslation'
disable 'ParcelCreator'
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
jacoco {
toolVersion = "$jacoco_version"
}
androidExtensions {
experimental true
}
configurations {
ktlint
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
task reportVersionCode {
new File("$projectDir/versionCode.txt").text = "$project.android.defaultConfig.versionCode"
}
// By running this task before builds, we guarantee that the same version is used for the fastlane
// to supply the automated changelogs.
preBuild.dependsOn reportVersionCode
task reportVersionName {
new File("$projectDir/versionName.txt").text = "$project.android.defaultConfig.versionName"
}
preBuild.dependsOn reportVersionName
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
task testAll(dependsOn: ['test', 'connectedAndroidTest']) {
description = "Run all unit and instrumented tests."
}
// This task is for generating coverage reports locally. It will run connected and unit tests if necessary.
task jacocoCoverageReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = [ '**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*' ]
def javaClasses = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
def kotlinClasses = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories.from = files(mainSrc)
classDirectories.from = files([javaClasses, kotlinClasses])
executionData.from = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
])
}
// This task is for generating coverage in CI. It will run unit tests if required but will only
// correctly report coverage if a 'coverage.ec' file has been moved into the workspace from Firebase.
task jacocoCoverageReportForCi(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = [ '**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*' ]
def javaClasses = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
def kotlinClasses = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories.from = files(mainSrc)
classDirectories.from = files([javaClasses, kotlinClasses])
executionData.from = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*.ec'
])
}
ext.architectures = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
//ext.libDir = "$project.projectDir/src/main/resources/lib"
ext.libDir = "$project.projectDir/src/main/jniLibs"
task downloadAssets(type: Download) {
def assetVersion = "v8.8.8"
def baseUrl = "https://github.com/CypherpunkArmory/UserLAnd-Assets-Support/releases/download/$assetVersion"
for (arch in architectures) {
src "$baseUrl/$arch-assets.zip"
dest buildDir
}
}
task fetchAssets(dependsOn: downloadAssets) {
doLast {
for (arch in architectures) {
delete "$buildDir/$arch"
copy {
from zipTree("$buildDir/$arch-assets.zip")
into "$buildDir/$arch"
}
copy {
from "$buildDir/$arch"
into "$libDir/$arch"
// Lib files must start with 'lib' and end with '.so.'
rename '(.*)', 'lib_$1.so'
}
new File("$libDir/$arch", "lib_arch.so").text = "$arch"
}
}
}
task checkIfAssetsMissing {
for (arch in architectures) {
File[] archLibDirContents = new File(libDir, arch).listFiles()
if (archLibDirContents == null || archLibDirContents.length == 0) {
dependsOn 'fetchAssets'
}
}
}
preBuild.dependsOn checkIfAssetsMissing
dependencies {
def moshi_version = '1.8.0'
def okhttp_version = '3.13.1'
def sentry_version = '1.7.22'
def slf4j_version = '1.7.26'
def jsch_version = '0.1.55'
def kotlinx_coroutines_version = '1.0.0'
def kotlin_jdk_version = '1.3.31'
// Androidx versions
def room_version = '2.1.0-beta01'
def lifecycle_version = '2.2.0-alpha01'
def support_library_version = '1.1.0-alpha06'
def preference_version = '1.1.0-alpha05'
def ktx_version = '1.0.2'
implementation project(':terminal-term')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_jdk_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinx_coroutines_version"
implementation "androidx.core:core-ktx:$ktx_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.preference:preference:$preference_version"
implementation "com.google.android.material:material:$support_library_version"
ktlint "com.pinterest:ktlint:0.32.0"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.moshi:moshi:$moshi_version"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
implementation 'org.rauschig:jarchivelib:0.8.0' // v1.0.0 breaks all sdk versions < 26 https://github.com/thrau/jarchivelib/issues/75
implementation "io.sentry:sentry-android:$sentry_version"
implementation "org.slf4j:slf4j-nop:$slf4j_version"
implementation "com.jcraft:jsch:$jsch_version"
def mockito_version = '2.23.0'
def mockito_kotlin_version = '2.1.0'
def core_testing_version = '2.0.0-beta01'
def androidx_test_version = '1.2.0'
def androidx_test_ext_version = '1.1.0'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation "org.mockito:mockito-inline:$mockito_version"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockito_kotlin_version"
testImplementation "androidx.arch.core:core-testing:$core_testing_version"
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
androidTestImplementation "androidx.arch.core:core-testing:$core_testing_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation "androidx.test:runner:$androidx_test_version"
androidTestImplementation "androidx.test:rules:$androidx_test_version"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_ext_version"
// Barista packages espresso-core and espresso-contrib
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
androidTestImplementation('com.schibsted.spain:barista:3.1.0') {
exclude group: 'com.android.support'
exclude group: 'org.jetbrains.kotlin'
}
androidTestUtil "androidx.test:orchestrator:$androidx_test_version"
}