apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'
apply from: 'jacoco.gradle'
apply from: 'sonarqube.gradle'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "io.github.wulkanowy"
        testApplicationId "io.github.tests.wulkanowy"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 32
        versionName "0.7.6"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        manifestPlaceholders = [
                fabric_api_key     : System.getenv("FABRIC_API_KEY") ?: "null",
                crashlytics_enabled: project.hasProperty("enableCrashlytics")
        ]
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    sourceSets {
        androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
    }

    signingConfigs {
        release {
            storeFile file("upload-key.jks")
            storePassword System.getenv("PLAY_STORE_PASSWORD")
            keyAlias System.getenv("PLAY_KEY_ALIAS")
            keyPassword System.getenv("PLAY_KEY_PASSWORD")
        }
    }

    buildTypes {
        release {
            buildConfigField "boolean", "CRASHLYTICS_ENABLED", "true"
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            buildConfigField "boolean", "CRASHLYTICS_ENABLED", project.hasProperty("enableCrashlytics") ? "true" : "false"
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
            testCoverageEnabled = true
            ext.enableCrashlytics = project.hasProperty("enableCrashlytics")
            multiDexKeepProguard file('proguard-multidex-rules.pro')
        }
    }

    lintOptions {
        disable 'HardwareIds'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

androidExtensions {
    experimental = true
}

play {
    serviceAccountEmail = System.getenv("PLAY_SERVICE_ACCOUNT_EMAIL") ?: "jan@fakelog.cf"
    serviceAccountCredentials = file('key.p12')
    defaultToAppBundles = true
    track = 'alpha'
}

dependencies {
    implementation 'com.github.wulkanowy:api:3335bd6'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "androidx.appcompat:appcompat:1.0.2"
    implementation 'androidx.multidex:multidex:2.0.1'

    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "com.google.android.material:material:1.1.0-alpha05"
    implementation 'com.github.wulkanowy:MaterialChipsInput:b72fd0ee6f'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

    implementation "androidx.work:work-runtime:2.0.1"
    implementation "androidx.work:work-rxjava2:2.0.1"

    implementation "androidx.room:room-runtime:2.1.0-alpha06"
    implementation "androidx.room:room-rxjava2:2.1.0-alpha06"
    kapt "androidx.room:room-compiler:2.1.0-alpha06"

    implementation "com.google.dagger:dagger-android-support:2.22.1"
    kapt "com.google.dagger:dagger-compiler:2.22.1"
    kapt "com.google.dagger:dagger-android-processor:2.22.1"
    implementation 'com.squareup.inject:assisted-inject-annotations-dagger2:0.4.0'
    kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0'

    implementation "eu.davidea:flexible-adapter:5.1.0"
    implementation "eu.davidea:flexible-adapter-ui:1.0.0"
    implementation "com.aurelhubert:ahbottomnavigation:2.3.4"
    implementation 'com.ncapdevi:frag-nav:3.2.0'

    implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.2'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation "io.reactivex.rxjava2:rxjava:2.2.8"

    implementation 'com.google.code.gson:gson:2.8.5'
    implementation "com.jakewharton.threetenabp:threetenabp:1.2.0"
    implementation "com.jakewharton.timber:timber:4.7.1"
    implementation "at.favre.lib:slf4j-timber:1.0.1"
    implementation "com.squareup.okhttp3:logging-interceptor:3.12.1"

    implementation "com.mikepenz:aboutlibraries:6.2.3"
    implementation 'com.takisoft.preferencex:preferencex:1.0.0'

    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'

    releaseImplementation 'fr.o80.chucker:library-no-op:2.0.4'

    debugImplementation 'fr.o80.chucker:library:2.0.4'
    debugImplementation "com.amitshekhar.android:debug-db:1.0.6"

    testImplementation "junit:junit:4.12"
    testImplementation "io.mockk:mockk:1.9.2"
    testImplementation "org.mockito:mockito-inline:2.27.0"
    testImplementation 'org.threeten:threetenbp:1.3.8'

    androidTestImplementation 'androidx.test:core:1.1.0'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation "io.mockk:mockk-android:1.9.2"
    androidTestImplementation 'org.mockito:mockito-android:2.27.0'
    androidTestImplementation "androidx.room:room-testing:2.1.0-alpha06"
    androidTestImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services'