buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        maven { url 'https://maven.fabric.io/public' }
        google()
    }

    dependencies {
        classpath "org.greenrobot:greendao-gradle-plugin:$greenDaoGradle"
        classpath "io.fabric.tools:gradle:$fabricGradle"
        classpath "com.google.gms:oss-licenses:0.9.2"
        classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'io.fabric'
apply from: '../jacoco.gradle'
apply from: '../android-sonarqube.gradle'
apply plugin: 'com.google.gms.oss.licenses.plugin'
apply plugin: 'com.github.triplet.play'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'

    playAccountConfigs {
        defaultAccountConfig {
            serviceAccountEmail = System.getenv("PLAY_SERVICE_ACCOUNT_EMAIL")
            pk12File = file('key.p12')
        }
    }

    defaultConfig {
        applicationId "io.github.wulkanowy"
        testApplicationId "io.github.tests.wulkanowy"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 8
        versionName "0.4.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        playAccountConfig = playAccountConfigs.defaultAccountConfig
        manifestPlaceholders = [
                fabricApiKey: System.getenv("FABRIC_API_KEY") ?: "null"
        ]
    }

    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 {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            applicationIdSuffix ".dev"
            versionNameSuffix "-dev"
            testCoverageEnabled = true
            ext.enableCrashlytics = false
        }
    }

    testOptions {
        unitTests.all {
            testLogging {
                events "passed", "skipped", "failed", "standardOut", "standardError"
                outputs.upToDateWhen { false }
                showStandardStreams = true
            }
        }
    }
}

play {
    track = 'alpha'
    uploadImages = true
}

greendao {
    schemaVersion 26
    generateTests = true
}

configurations.all {
    resolutionStrategy.force "com.android.support:support-annotations:$supportVersion"
}

dependencies {
    implementation project(':api')
    implementation "com.android.support:support-v4:$supportVersion"
    implementation "com.android.support:design:$supportVersion"
    implementation "com.android.support:cardview-v7:$supportVersion"
    implementation "com.android.support:customtabs:$supportVersion"
    implementation "com.android.support:preference-v14:$supportVersion"
    implementation "com.firebase:firebase-jobdispatcher:$firebaseJob"
    implementation "org.apache.commons:commons-lang3:$apacheLang"
    implementation "org.apache.commons:commons-collections4:$apacheCollections"
    implementation "eu.davidea:flexible-adapter:$flexibleAdapter"
    implementation "eu.davidea:flexible-adapter-ui:$flexibleUi"
    implementation "org.greenrobot:greendao:$greenDao"
    implementation "com.jakewharton:butterknife:$butterknife"
    implementation "com.google.dagger:dagger-android-support:$dagger2"
    implementation "com.aurelhubert:ahbottomnavigation:$ahbottom"
    implementation "com.jakewharton.threetenabp:threetenabp:$threeTenABP"
    implementation "com.google.android.gms:play-services-oss-licenses:$ossLicenses"

    implementation("com.crashlytics.sdk.android:crashlytics:$crashlyticsSdk@aar") {
        transitive = true
    }
    implementation("com.crashlytics.sdk.android:answers:$crashlyticsAnswers@aar") {
        transitive = true
    }

    annotationProcessor "com.google.dagger:dagger-android-processor:$dagger2"
    annotationProcessor "com.google.dagger:dagger-compiler:$dagger2"
    annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife"

    debugImplementation "com.amitshekhar.android:debug-db:$debugDb"
    debugImplementation "net.zetetic:android-database-sqlcipher:$sqlcipher"

    testImplementation "junit:junit:$junit"
    testImplementation "org.mockito:mockito-core:$mockito"

    androidTestImplementation "com.android.support.test:runner:$testRunner"
    androidTestImplementation "org.mockito:mockito-android:$mockito"
}
