apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))

def isTravis = "true" == System.getenv("TRAVIS")
def preDexEnabled = "true" == System.getProperty("pre-dex", "true")

android {
    compileSdkVersion rootProject.sdkVersion
    buildToolsVersion rootProject.buildTools

    dexOptions {
        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
        preDexLibraries = preDexEnabled && !isTravis
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    defaultConfig {
        applicationId "org.fossasia.openevent"
        targetSdkVersion rootProject.sdkVersion
        minSdkVersion rootProject.minSdkVersion
        versionCode 101
        versionName "1.0.1"

        vectorDrawables.useSupportLibrary = true

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
        buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""

        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "tier"
    productFlavors {
        fdroid {
            dimension "tier"
        }
        googleplay {
            dimension "tier"
        }
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/LICENSE'
    }
    lintOptions {
        abortOnError false
        disable 'InvalidPackage'
    }

    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    androidExtensions {
        experimental = true
    }

    sourceSets.test.resources.srcDirs += ["src/main/assets"]
}

configurations.all {
    resolutionStrategy {
        force 'com.android.support:multidex:1.0.2'
    }
}

def SUPPORT_LIB_VERSION = "27.1.0"

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:appcompat-v7:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:support-v4:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:cardview-v7:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:recyclerview-v7:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:design:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:customtabs:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:palette-v7:${SUPPORT_LIB_VERSION}"
    implementation 'com.android.support:multidex:1.0.3'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation project(':data')
    
    implementation 'com.github.jasminb:jsonapi-converter:0.8.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
    implementation 'com.jakewharton.threetenabp:threetenabp:1.0.5'
    implementation 'com.squareup:otto:1.3.8'
    implementation 'com.jakewharton.timber:timber:4.6.0'
    implementation 'com.jakewharton:butterknife:8.8.1'
    kapt 'com.jakewharton:butterknife-compiler:8.8.1'
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
    implementation 'com.uphyca:stetho_realm:2.1.0'
    implementation 'com.github.yalantis:ucrop:2.2.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.10'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

    // Googleplay Variant
    googleplayImplementation 'com.google.android.gms:play-services-maps:12.0.0'
    googleplayImplementation 'com.google.android.gms:play-services-location:12.0.0'
    googleplayImplementation 'com.google.maps.android:android-maps-utils:0.4'

    // Fdroid Variant
    fdroidImplementation 'org.osmdroid:osmdroid-android:5.1'
    fdroidImplementation 'org.apache.directory.studio:org.slf4j.api:1.7.2'
    fdroidImplementation 'org.slf4j:slf4j-simple:1.7.14'

    // Unit Test
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.13.0'
    testImplementation 'org.threeten:threetenbp:1.3.6'

    // Instrumentation Test
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // Catch all the leaks
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
    testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

    // Branch integration for deep linking
    implementation ('io.branch.sdk.android:library:2.5.9') {
        exclude module: 'answers-shim'
    }

    // Architecture Components
    implementation "android.arch.lifecycle:extensions:1.1.0"
    implementation "android.arch.lifecycle:reactivestreams:1.1.0"

    // Zoomable image view
    implementation 'com.github.chrisbanes:PhotoView:2.1.3'

    // fast scroll rv
    implementation 'com.futuremind.recyclerfastscroll:fastscroll:0.2.5'
}
