apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'kotlin-parcelize'
apply plugin: "de.timfreiheit.resourceplaceholders"
apply plugin: 'kotlin-kapt'

static def releaseTime() {
    return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
}

def name = "YueDu"
def version = "2." + releaseTime()
def gitCommits = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())

android {
    compileSdkVersion 31
    signingConfigs {
        myConfig {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_KEY_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_STORE_PASSWORD
        }
    }

    defaultConfig {
        applicationId "com.gedoor.monkeybook"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 10000 + gitCommits
        versionName version
        project.ext.set("archivesBaseName", name + "_" + version)
        multiDexEnabled true

    }
    buildFeatures {
        viewBinding true
    }
    lintOptions {
        abortOnError false
    }
    buildTypes {
        release {
            signingConfig signingConfigs.myConfig
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            signingConfig signingConfigs.myConfig
            applicationIdSuffix '.debug'
            versionNameSuffix 'debug'
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        android.applicationVariants.all { variant ->
            variant.outputs.all {
                outputFileName = "${name}_${defaultConfig.versionName}.apk"
            }
        }
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildToolsVersion '30.0.3'
    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:unchecked"
        //options.compilerArgs << "-Xlint:deprecation"
    }
}

resourcePlaceholders {
    files = ['xml/shortcuts.xml']
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
    testImplementation 'junit:junit:4.13.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':basemvplib')
    implementation('androidx.multidex:multidex:2.0.1')
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    //协程
    def coroutines_version = '1.6.0'
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")

    //anko
    def anko_version = '0.10.8'
    implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
    implementation "org.jetbrains.anko:anko-sdk27-listeners:$anko_version"

    //lifecycle
    def lifecycle_version = '2.4.1'
    implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")

    //androidX
    implementation('androidx.appcompat:appcompat:1.4.1')
    implementation('androidx.core:core-ktx:1.7.0')
    implementation("androidx.activity:activity-ktx:1.4.0")
    implementation("androidx.fragment:fragment-ktx:1.4.1")
    implementation('androidx.preference:preference-ktx:1.2.0')
    implementation('androidx.constraintlayout:constraintlayout:2.1.3')
    implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
    implementation('androidx.viewpager2:viewpager2:1.0.0')
    implementation('com.google.android.material:material:1.5.0')
    implementation('com.google.android.flexbox:flexbox:3.0.0')
    implementation('com.google.code.gson:gson:2.9.0')
    implementation('androidx.webkit:webkit:1.4.0')

    //Splitties
    def splitties_version = '3.0.0'
    implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
    implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
    implementation("com.louiscad.splitties:splitties-views:$splitties_version")

    //media
    implementation("androidx.media:media:1.5.0")
    def exoplayer_version = '2.17.1'
    implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
    implementation "com.google.android.exoplayer:extension-okhttp:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayer_version"
    implementation "com.google.android.exoplayer:exoplayer-rtsp:$exoplayer_version"

    //google
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'com.google.code.gson:gson:2.9.0'

    //RxAndroid
    implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

    //RxBus
    implementation 'com.hwangjr.rxbus:rxbus:2.0.1'

    //Retrofit
    //noinspection GradleDependency
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'

    //J_SOUP
    implementation 'org.jsoup:jsoup:1.14.3'
    implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'
    implementation 'com.jayway.jsonpath:json-path:2.7.0'

    //JS
    //noinspection GradleDependency
    implementation 'com.github.gedoor:rhino-android:1.3'

    //GreenDao
    implementation 'org.greenrobot:greendao:3.3.0'
    implementation 'com.github.yuweiguocn:GreenDaoUpgradeHelper:v2.2.1'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.13.1'
    kapt 'com.github.bumptech.glide:compiler:4.13.1'

    //CircleImageView
    implementation 'de.hdodenhof:circleimageview:3.1.0'

    //webServer
    implementation 'org.nanohttpd:nanohttpd:2.3.1'
    implementation 'org.nanohttpd:nanohttpd-websocket:2.3.1'

    //二维码
    implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7'

    //颜色选择
    implementation 'com.jaredrummler:colorpicker:1.1.0'

    //apache
    implementation('org.apache.commons:commons-text:1.9')

    //简繁转换
    implementation 'com.luhuiguo:chinese-utils:1.0'

    //字符串比较
    implementation 'net.ricecode:string-similarity:1.0.0'

    //MarkDown
    implementation 'ru.noties.markwon:core:3.1.0'

    //epub
    implementation('com.positiondev.epublib:epublib-core:3.1') {
        exclude group: 'org.slf4j'
        exclude group: 'xmlpull'
    }

}

greendao {
    schemaVersion 68
    daoPackage 'com.kunfei.bookshelf.dao'
    targetGenDir 'src/main/java'
}

afterEvaluate {
//    for (Task task : project.tasks.matching { it.name.startsWith('crashlyticsUploadDeobs') }) {
//        task.enabled = false
//    }
}

