import java.util.zip.ZipFile

apply plugin: 'com.android.application'

apply from: "../private/privateResource.gradle"

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "com.zzzmode.appopsx"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        signingConfig signingConfigs.debug
        //resConfigs "en","zh-rCN","zh-rTW","cs"
        vectorDrawables.useSupportLibrary = true
        manifestPlaceholders = [gitCommitId:"${GIT_COMMIT_ID}"]
    }

    aaptOptions {
        noCompress 'jar','sh'
    }

    lintOptions {
        abortOnError false
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    signingConfigs {
        release{
            storeFile JEK_FILE_DECRYPTED
            keyAlias project.myEnv.KEY_ALIAS
            storePassword project.myEnv.STORE_PASSWORD
            keyPassword project.myEnv.KEY_PASSWORD
        }
    }

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

def supportVersion= '1.0.0'

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    compileOnly fileTree(include: ['*.jar'], dir: 'deps')
    implementation project(":opsxpro")
    implementation "androidx.appcompat:appcompat:1.0.2"
    implementation "androidx.recyclerview:recyclerview:$supportVersion"
    implementation "androidx.preference:preference:1.1.0-alpha02"
    implementation "androidx.legacy:legacy-preference-v14:$supportVersion"
    implementation "com.google.android.material:material:$supportVersion"
    implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    implementation 'com.github.promeg:tinypinyin:2.0.3'
    implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0'
}


task providedApiCompat  {

    doLast {

        println("------------- providedApiCompat ")

        new ZipFile("${rootProject.project("apicompat").buildDir}/outputs/aar/apicompat-debug.aar").withCloseable {

            it.getInputStream(it.getEntry("classes.jar")).withStream{
                def ins = it
                def target = file("${project.projectDir}/deps/hidden.jar")
                target.getParentFile().mkdirs()
                target.withOutputStream {
                    it << ins
                }
            }
        }

    }

}


providedApiCompat.dependsOn(':apicompat:assembleDebug')
preBuild.dependsOn(providedApiCompat)


