buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

def versionMajor = 1
def versionMinor = 4
def versionPatch = 7
def versionBuild = 0

apply plugin: 'com.android.application'

if (project.file('crashlytics.properties').exists()) {
    apply plugin: 'io.fabric'
}

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

dependencies {
    compile  'com.android.support:support-v4:22.2.+'
    compile  'com.android.support:appcompat-v7:22.2.+'
    compile  'com.android.support:cardview-v7:22.2.+'
    compile  'com.android.support:recyclerview-v7:22.2.+'
    compile  'com.android.support:gridlayout-v7:22.1.+'
    compile  'com.android.support:palette-v7:22.1.+'
    compile  'com.nineoldandroids:library:2.4.0'

    compile  'com.squareup.dagger:dagger:1.2.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'

    compile  'com.jakewharton:butterknife:6.0.0'
    compile  'com.jakewharton.timber:timber:2.5.0'
    compile  'org.parceler:parceler-api:0.2.15'
    provided 'org.parceler:parceler:0.2.15'

    compile 'org.jsoup:jsoup:1.7.3'

    compile  'com.koushikdutta.ion:ion:2.1.3'

    // TODO: Update to 1.2.4 once it's out (https://github.com/chrisbanes/PhotoView/issues/72)
    compile  'com.github.chrisbanes.photoview:library:1.2.2'

    compile project(':libs:fenster')

    compile ('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
        transitive = true;
    }
}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "anabolicandroids.chanobol"
        minSdkVersion 15
        targetSdkVersion 22

        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true

        versionCode versionMajor * 100000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
    }

    /*
    If you want to sign releases, make a file keys.properties with the following content:
    keystoreFile=yourkey.store
    keystorePass=pass
    keyAlias=alias
    keyPass=pass
    */

    File f = file('keys.properties')
    boolean doSign = f.exists();

    if (doSign) {
        Properties props = new Properties()
        props.load(new FileInputStream(f))

        //noinspection GroovyAssignabilityCheck
        signingConfigs {
            release {
                storeFile file(props['keystoreFile'])
                storePassword props['keystorePass']
                keyAlias props['keyAlias']
                keyPassword props['keyPass']
            }
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix '.dev'
            versionNameSuffix '-dev'
        }
        //noinspection GroovyMissingReturnStatement
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (doSign) {
                signingConfig signingConfigs.release
            }
        }
        release_sfw {
            initWith buildTypes.release
            applicationIdSuffix '.reallysfw'
        }
    }
    lintOptions {
        disable 'InvalidPackage'
    }
}

