apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'org.jetbrains.dokka'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "net.swiftzer.android.metroride"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

    signingConfigs {
        debug {
            storeFile file("../app/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.debug
            applicationIdSuffix dev_app_id_suffex
            versionNameSuffix dev_version_name_suffex
        }
        debugStetho {
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.debug
            applicationIdSuffix dev_app_id_suffex
            versionNameSuffix dev_version_name_suffex
        }
        debugLeakCanary {
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.debug
            applicationIdSuffix dev_app_id_suffex
            versionNameSuffix dev_version_name_suffex
        }
        debugProGuard {
            debuggable true
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.debug
            applicationIdSuffix dev_app_id_suffex
            versionNameSuffix dev_version_name_suffex
        }
        release {
            minifyEnabled true
            shrinkResources true
        }
    }

    packagingOptions {
        // Exclude files to avoid packaging collisions (same file name in multiple dependencies).
        exclude 'LICENSE.txt'
    }

    lintOptions {
        abortOnError false
    }

    dokka {
        moduleName = 'app'
        outputFormat = 'html'
        outputDirectory = "$buildDir/kdoc"
        linkMapping {
            dir = "src/main/java"
            url = "https://gitlab.com/mtrupdate/metroride-android/tree/master/app/src/main/java"
            suffix = "#L"
        }
        sourceDirs = files('src/main/java')
    }
}

kapt {
    generateStubs = true
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // Kotlin language
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    // Android support
    compile "com.android.support:support-annotations:$android_support_version"
    compile "com.android.support:appcompat-v7:$android_support_version"
    compile "com.android.support:design:$android_support_version"
    compile "com.android.support:cardview-v7:$android_support_version"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    // Firebase
    compile "com.google.firebase:firebase-core:$firebase_version"
    compile "com.google.firebase:firebase-crash:$firebase_version"
    compile "com.google.firebase:firebase-messaging:$firebase_version"
    compile "com.google.firebase:firebase-config:$firebase_version"

    compile "org.jetbrains.anko:anko-common:$anko_version"
    compile 'com.squareup.okhttp3:okhttp:3.6.0'
    compile "com.squareup.retrofit2:retrofit:$retrofit_version"
    compile "com.squareup.retrofit2:converter-moshi:$retrofit_version"
    compile 'com.squareup.moshi:moshi:1.4.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
//    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
    compile 'com.jakewharton.timber:timber:4.5.1'

    // Dagger 2
    compile "com.google.dagger:dagger:$dagger_version"
    compile "com.google.dagger:dagger-android:$dagger_version"
    compile "com.google.dagger:dagger-android-support:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"
    kapt "com.google.dagger:dagger-android-processor:$dagger_version"
    provided 'org.glassfish:javax.annotation:10.0-b28'

    // Stetho
    debugStethoCompile "com.facebook.stetho:stetho:$stetho_version"
    debugStethoCompile "com.facebook.stetho:stetho-okhttp3:$stetho_version"
    debugStethoCompile 'com.uphyca:stetho_realm:2.0.0'

    // LeakCanary
    debugLeakCanaryCompile "com.squareup.leakcanary:leakcanary-android:$leak_canary_version"
    debugCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
    debugStethoCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
    debugProGuardCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
    releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"

    // Testing
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', module: 'jsr305'
    })
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:2.+'

    // Spek
    testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    testCompile("org.jetbrains.spek:spek-api:$spek_version") {
        exclude group: 'org.jetbrains.kotlin'
    }
    testCompile("org.jetbrains.spek:spek-junit-platform-engine:$spek_version") {
        exclude group: 'org.junit.platform'
        exclude group: 'org.jetbrains.kotlin'
    }
    testCompile 'org.junit.platform:junit-platform-runner:1.0.0-M3'
    testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

    testCompile 'com.opencsv:opencsv:3.8'
}

apply plugin: 'com.google.gms.google-services'
