apply plugin: 'com.android.application'
//apply plugin: 'com.github.gfx.android.powerassert'
apply plugin: 'com.github.gfx.ribbonizer'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'com.cookpad.android.licensetools'

apply from: 'https://raw.githubusercontent.com/gfx/gradle-android-utils/master/build.gradle'

repositories {
    jcenter()
}

tasks.withType(JavaCompile) {
    options.compilerArgs << "-Xlint:all" << "-Xlint:-processing"
}

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    dataBinding.enabled = true
    defaultConfig {
        applicationId "com.github.gfx.helium"
        minSdkVersion 16
        targetSdkVersion 25
        def version = readVersion(rootProject.file("VERSION"))
        versionName version.toVersionName()
        versionCode version.toVersionCode()
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        resConfigs "ja"
    }
    signingConfigs {
        debug {
            storeFile rootProject.file("debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
        release {
            if (project.ext.has('ReleaseStoreFile')) {
                storeFile file(project.ext.ReleaseStoreFile.replaceAll("~", System.getenv("HOME")))
                storePassword project.ext.ReleaseStorePassword
                keyAlias project.ext.ReleaseKeyAlias
                keyPassword project.ext.ReleaseKeyPassword
            } else {
                storeFile rootProject.file("debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
    }
    buildTypes {
        debug {
            debuggable true
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            signingConfig signingConfigs.debug

            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            buildConfigField("String", "GA_TRACKING_ID",
                    "\"${project.ext.has('GA_TRACKING_ID_DEBUG') ? project.ext.GA_TRACKING_ID_DEBUG : ''}\"")
        }

        beta {
            debuggable true
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"

            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.debug

            buildConfigField("String", "GA_TRACKING_ID",
                    "\"${project.ext.has('GA_TRACKING_ID_DEBUG') ? project.ext.GA_TRACKING_ID_DEBUG : ''}\"")
        }

        release {
            debuggable false
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            if (signingConfigs.release.storeFile != null &&
                    signingConfigs.release.storeFile.exists()) {
                signingConfig signingConfigs.release
            } else {
                logger.info(
                        "keystore ${signingConfigs.release.storeFile} does not exist. Release signing is ignored.")
            }

            buildConfigField("String", "GA_TRACKING_ID",
                    "\"${project.ext.has('GA_TRACKING_ID_RELEASE') ? project.ext.GA_TRACKING_ID_RELEASE : ''}\"")
        }
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    dexOptions {
        preDexLibraries = !System.getenv("CI")
    }
}

ext {
    supportLibraryVersion = '25.3.1'
}

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

dependencies {
    compile "com.android.support:support-v4:$supportLibraryVersion"
    compile "com.android.support:appcompat-v7:$supportLibraryVersion"
    compile "com.android.support:cardview-v7:$supportLibraryVersion"
    compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
    compile "com.android.support:design:$supportLibraryVersion"
    compile "com.android.support:support-annotations:$supportLibraryVersion"
    compile 'com.google.android.gms:play-services-analytics:9.6.1'
    compile 'com.google.code.findbugs:jsr305:3.0.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile('com.squareup.retrofit2:converter-simplexml:2.1.0') {
        exclude module: 'stax'
        exclude module: 'stax-api'
        exclude module: 'xpp3'
    }
    compile 'com.cookpad.android.rxt4a:rxt4a:1.0.0'
    compile 'io.reactivex:rxjava:1.2.2'
    compile 'com.artemzin.rxjava:proguard-rules:1.2.2.0'
    compile 'com.jakewharton.threetenabp:threetenabp:1.0.4'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
    compile 'com.google.dagger:dagger:2.7'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
    provided 'javax.annotation:jsr250-api:1.0'
    annotationProcessor 'com.github.gfx.android.orma:orma-processor:3.2.1'
    compile 'com.github.gfx.android.orma:orma:3.2.1'
    annotationProcessor 'com.github.gfx.static_gson:static-gson-processor:0.9.7'
    compile 'com.github.gfx.static_gson:static-gson:0.9.7'
    debugCompile 'com.facebook.stetho:stetho:1.3.1'
    debugCompile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
    betaCompile 'com.facebook.stetho:stetho:1.3.1'
    betaCompile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
    // power-assert plugin depends on commons-lang3
    betaCompile 'org.apache.commons:commons-lang3:3.4'
    testCompile 'com.github.gfx.android.robolectricinstrumentation:robolectric-instrumentation:3.1.4'
    testCompile 'junit:junit:4.12'
    testCompile 'org.hamcrest:hamcrest-library:1.3'
    testCompile 'com.google.guava:guava:19.0'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
    androidTestCompile 'com.google.guava:guava:19.0'
}
