apply plugin: "com.android.application"

apply plugin: "kotlin-android"

apply plugin: "kotlin-android-extensions"

apply plugin: "kotlin-kapt"

def cmd = "git rev-list HEAD --count"
def gitVersion = cmd.execute().text.trim().toInteger()

static def getAlphaVersionName() {
    "alpha" + new Date().format("yyyyMMdd")
}

android {
    packagingOptions {
        exclude "lib/*/libRSSupport.so"
        exclude "lib/*/librsjni.so"
        exclude "lib/*/librsjni_androidx.so"
    }

    compileSdkVersion 30
    buildToolsVersion '30.0.3'
    defaultConfig {
        applicationId "soko.ekibun.bangumi"
        minSdkVersion 22
        targetSdkVersion 30
        versionCode gitVersion
        versionName getAlphaVersionName()
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField "boolean", "AUTO_UPDATES", "true"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    ndkVersion ="22.1.7171670"

    signingConfigs {
        debug {
            keyAlias 'ekibun'
            keyPassword 'ekibun'
            storeFile file('D:/OneDrive/ekibun.jks')
            storePassword 'ekibun'
        }
    }

    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    flavorDimensions "versionCode"
    productFlavors {
        github {
            dimension "versionCode"
        }
    }
}

dependencies {
    implementation fileTree(include: ["*.jar"], dir: "libs")
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

    implementation "com.google.android.material:material:$materialVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
    implementation "androidx.room:room-runtime:$roomVersion"
    kapt "androidx.room:room-compiler:$roomVersion"
    implementation "androidx.room:room-ktx:$roomVersion"

    implementation "com.github.bumptech.glide:glide:$glideVersion"
    kapt "com.github.bumptech.glide:compiler:$glideVersion"
    implementation "com.zlc.glide:webpdecoder:1.7.$glideVersion"
    implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion"

    implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
    implementation "com.squareup.okhttp3:okhttp-brotli:$okhttpVersion"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"

    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$archLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$archLifecycleVersion"

    implementation "androidx.core:core-ktx:1.3.1"
    implementation "androidx.preference:preference:1.1.0"
    testImplementation "junit:junit:4.12"
    androidTestImplementation "androidx.test:runner:1.2.0"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
    implementation "androidx.constraintlayout:constraintlayout:1.1.3"
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation "com.google.code.gson:gson:2.8.6"
    implementation "org.jsoup:jsoup:1.13.1"
    implementation "com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.3"
    implementation "jp.wasabeef:glide-transformations:4.0.1"
    implementation "com.github.siyamed:android-shape-imageview:0.9.3"
    implementation "com.zhy:base-adapter:3.0.3"
    implementation "com.nshmura:recyclertablayout:1.5.0"
    implementation "com.github.chrisbanes:PhotoView:2.1.4"
    implementation "am.util:viewpager:25.3.0"
    implementation "com.jakewharton:disklrucache:2.0.2"
    implementation "com.caverock:androidsvg-aar:1.4"
}
