apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'org.jlleitschuh.gradle.ktlint'

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.30.0'
        classpath "org.jlleitschuh.gradle:ktlint-gradle:8.2.0"
    }
}

def STRING = 'String'
def BUILD_TIME = 'BUILD_TIME'


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

android {

    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.furkanaskin.app.podpocket"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 2
        versionName "0.1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField STRING, BUILD_TIME, "\"${rootProject.ext.buildTime}\""

        manifestPlaceholders = [
                pushbots_app_id  : "5d602b0bb7941205307ed81a",
                pushbots_loglevel: "DEBUG",
                google_sender_id : "907664402095"
        ]
    }
    buildTypes {
        release {
            minifyEnabled true
            zipAlignEnabled true
            shrinkResources true
            debuggable false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            ext.enableCrashlytics = false
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/atomicfu.kotlin_module'
        exclude 'META-INF/rxjava.properties'
    }
    dataBinding {
        enabled = true
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    androidExtensions {
        experimental = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation rootProject.ext.supportv4
    implementation rootProject.ext.appCompat
    implementation rootProject.ext.materialDesign
    implementation rootProject.ext.recyclerView
    implementation rootProject.ext.cardView
    implementation rootProject.ext.coreKtx
    implementation rootProject.ext.firebaseCore
    implementation rootProject.ext.firebaseDatabase
    implementation rootProject.ext.firebaseAuth
    implementation rootProject.ext.firebaseStorage
    implementation rootProject.ext.firebaseUiStorage
    implementation rootProject.ext.firebaseMessaging
    implementation rootProject.ext.pushBots
    implementation rootProject.ext.threetenabp
    implementation rootProject.ext.lottie
    implementation rootProject.ext.scalingLayout
    implementation rootProject.ext.circularImageView
    implementation rootProject.ext.timber
    implementation rootProject.ext.navigationFragment
    implementation rootProject.ext.navigationUI
    implementation rootProject.ext.dagger
    implementation rootProject.ext.daggerSupport
    kapt rootProject.ext.daggerApt
    kapt rootProject.ext.daggerAnnotation
    implementation rootProject.ext.rxJava
    implementation rootProject.ext.rxAndroid
    implementation rootProject.ext.rxKotlin
    implementation rootProject.ext.rxAnimations
    implementation rootProject.ext.simpleText
    implementation rootProject.ext.retrofit
    implementation rootProject.ext.okHttp
    implementation rootProject.ext.gson
    implementation rootProject.ext.rxJavaAdapter
    implementation rootProject.ext.gsonConverter
    implementation rootProject.ext.picasso
    implementation rootProject.ext.glide
    annotationProcessor rootProject.ext.glideAnnotation
    implementation rootProject.ext.coroutinesCore
    implementation rootProject.ext.anko
    implementation rootProject.ext.ankoCoroutines
    implementation rootProject.ext.lifecycleExt
    annotationProcessor rootProject.ext.lifecycleAnnotation
    implementation rootProject.ext.lifecycleViewModelKtx
    implementation rootProject.ext.roomRuntime
    kapt rootProject.ext.roomCompiler
    implementation rootProject.ext.pagingRuntime
    kapt rootProject.ext.dataBindingCompilerKapt
    annotationProcessor rootProject.ext.dataBindingCompilerAnnotation
    implementation rootProject.ext.stethoCore
    implementation rootProject.ext.stethoOkHttp
    implementation rootProject.ext.stethoUrlConnection
    implementation rootProject.ext.exoPlayer
    implementation rootProject.ext.flagKit
    implementation rootProject.ext.timeAgo
    implementation rootProject.ext.autoDispose
    implementation rootProject.ext.autoDisposeAndroidExt
    implementation rootProject.ext.autoDisposeLifecycle
    implementation rootProject.ext.autoDisposeArchComponents
    implementation(rootProject.ext.crashlytics) {
        transitive = true
    }

    testImplementation rootProject.ext.jUnit
    testImplementation rootProject.ext.archCoreTest
    testImplementation rootProject.ext.roomTest
    testImplementation rootProject.ext.pagingTest

    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs'
    })
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
repositories {
    mavenCentral()
}

ktlint {
    debug = true
    verbose = true
    android = false
    outputToConsole = true
    ignoreFailures = true
    enableExperimentalRules = true
    additionalEditorconfigFile = file("/some/additional/.editorconfig")
    kotlinScriptAdditionalPaths {
        include fileTree("scripts/")
    }
    filter {
        exclude("**/generated/**")
        include("**/kotlin/**")
    }
}
