buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        classpath 'com.google.gms:google-services:3.1.0'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.j2objcgradle.gradle'

Properties properties = new Properties()
try {
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
catch(Exception e)
{
    //Meh
}
def baseurl = properties.hasProperty('baseurl') ? properties.getProperty('baseurl') : 'https://droidcon-server.herokuapp.com/'
def amazonurl = properties.hasProperty('amazonurl') ? properties.getProperty('amazonurl') : 'https://s3.amazonaws.com/'
def releasePassword = properties.getProperty('releasePassword')

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "co.touchlab.droidcon.sf2017"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 107
        versionName "1.0.7"

        buildConfigField "String", "BASE_URL", "\"$baseurl\""
        buildConfigField "String", "AMAZON_URL", "\"$amazonurl\""
        vectorDrawables.useSupportLibrary = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    signingConfigs {
        debug {
            storeFile file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        /*staging {
            storeFile file("release.jks")
            keyAlias "android"
            storePassword "$releasePassword"
            keyPassword "$releasePassword"
        }*/
        release {
            storeFile file("release.jks")
            keyAlias "key0"
            storePassword "$releasePassword"
            keyPassword "$releasePassword"
        }
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            pseudoLocalesEnabled true
        }
        /*staging {
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.release
        }*/
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/maven/org.apache.commons/commons-lang3/pom.xml'
        exclude 'META-INF/maven/org.apache.commons/commons-lang3/pom.properties'
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        abortOnError false
    }
}

def supportVersion = "26.1.0"
def daggerVer = doppl_dagger_java

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation "com.android.support:support-v4:$supportVersion"
    implementation "com.android.support:appcompat-v7:$supportVersion"
    implementation "com.android.support:design:$supportVersion"
    implementation "com.android.support:palette-v7:$supportVersion"
    implementation "com.android.support:recyclerview-v7:$supportVersion"
    implementation "com.android.support:cardview-v7:$supportVersion"
    implementation "com.android.support:customtabs:$supportVersion"

    annotationProcessor "android.arch.lifecycle:compiler:$doppl_arch_lifecycle_ext_java"

    implementation "android.arch.lifecycle:runtime:$doppl_arch_lifecycle_java"
    j2objc "co.doppl.android.arch.lifecycle:runtime:$doppl_arch_lifecycle_doppl"

    implementation "android.arch.lifecycle:extensions:$doppl_arch_lifecycle_ext_java"
    j2objc "co.doppl.android.arch.lifecycle:extensions:$doppl_arch_lifecycle_ext_doppl"

    annotationProcessor "android.arch.persistence.room:compiler:$doppl_arch_room_java"

    implementation "android.arch.persistence.room:runtime:$doppl_arch_room_java"
    j2objc "co.doppl.android.arch.persistence.room:runtime:$doppl_arch_room_doppl"

    implementation "android.arch.persistence.room:rxjava2:$doppl_arch_room_java"
    j2objc "co.doppl.android.arch.persistence.room:rxjava2:$doppl_arch_room_doppl"

    implementation 'com.squareup.okhttp:okhttp:2.7.5'
    implementation 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'

    implementation 'com.viewpagerindicator:library:2.4.1@aar'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'

    j2objc "co.doppl.lib:androidbase:$doppl_core_java"
    testImplementation "co.doppl.lib:androidbasetest:$doppl_core_java"
    testJ2objc "co.doppl.lib:androidbasetest:$doppl_core_doppl"

    implementation "com.squareup.retrofit2:retrofit:$doppl_retrofit2_java"
    implementation "com.squareup.retrofit2:converter-gson:$doppl_retrofit2_java"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$doppl_retrofit2_java"
    implementation "co.doppl.com.squareup.retrofit2.urlsession:retrofitfactory:$doppl_retrofit2_java"

    j2objc "co.doppl.com.squareup.retrofit2.urlsession:retrofit:$doppl_retrofit2_doppl"
    j2objc "co.doppl.com.squareup.retrofit2.urlsession:converter-gson:$doppl_retrofit2_doppl"
    j2objc "co.doppl.com.squareup.retrofit2.urlsession:adapter-rxjava2:$doppl_retrofit2_doppl"
    j2objc "co.doppl.com.squareup.retrofit2.urlsession:retrofitfactory:$doppl_retrofit2_doppl"

    implementation "io.reactivex.rxjava2:rxjava:$doppl_rxjava2_java"
    j2objc "co.doppl.io.reactivex.rxjava2:rxjava:$doppl_rxjava2_doppl"
    implementation "io.reactivex.rxjava2:rxandroid:$doppl_rxandroid_java"
    j2objc "co.doppl.io.reactivex.rxjava2:rxandroid:$doppl_rxandroid_doppl"

    implementation "com.google.dagger:dagger:$daggerVer"
    annotationProcessor "com.google.dagger:dagger-compiler:$daggerVer"
    testAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerVer"
    compileOnly 'javax.annotation:jsr250-api:1.0'
    j2objc "co.doppl.com.google.dagger:dagger:$doppl_dagger_doppl"

    implementation 'com.google.firebase:firebase-messaging:11.4.2'

    testImplementation "junit:junit:$doppl_junit_java"
    testJ2objc "org.j2objcgradle.junit:junit:$doppl_junit_doppl"

    testImplementation "org.mockito:mockito-core:$doppl_mockito_java"
    testJ2objc "org.j2objcgradle.org.mockito:mockito-core:$doppl_mockito_doppl"

    testImplementation "org.robolectric:robolectric:3.6.1"
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true
    }
}


j2objcConfig {
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.dagger', 'DDAG'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.data', 'DDAT'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.data.dao', 'DDAO'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.interactors', 'DINT'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.ios', 'DIOS'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.network', 'DNET'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.network.dao', 'DNETD'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.viewmodel', 'DVM'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared.utils', 'DUT'
    translatedPathPrefix 'co.touchlab.droidconandroid.shared', 'D'

    javaDebug true

    testIdentifier {
        include "**/*Test.java"
        exclude "**/OneTest.java"
    }

    translatePattern {
        include '**/shared/**'
        include '**/CrashReport.*'
        include '**/BuildConfig.*'
    }

    mainFramework{
        flagObjc = false
    }
}

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