ext.alwaysLib = true //虽然apply了cc-settings-2.gradle，但一直作为library编译，否则别的组件依赖此module时会报错
apply from: rootProject.file("cc-settings.gradle")
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion rootProject.ext.android["compileSdkVersion"]

    defaultConfig {
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        multiDexEnabled true
    }

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        debug {
            buildConfigField "boolean", "LOG_DEBUG", rootProject.ext.buildType["debugLogDebug"]
            buildConfigField "boolean", "USE_CANARY", rootProject.ext.buildType["debugUseCanary"]
            minifyEnabled false
            proguardFiles 'proguard-rules.pro'
        }
        release {
            buildConfigField "boolean", "LOG_DEBUG", rootProject.ext.buildType["releaseLogDebug"]
            buildConfigField "boolean", "USE_CANARY", rootProject.ext.buildType["releaseUseCanary"]
            minifyEnabled false
            zipAlignEnabled false
            proguardFiles 'proguard-rules.pro'
        }
    }

//    libraryVariants.all{ variant ->
//        variant.mergeResources.doLast {
//            replaceTheme variant
//        }
//    }
//    testVariants.all { variant ->
//        variant.mergeResources.doLast {
//            replaceTheme variant
//        }
//    }
}

//def replaceTheme(variant){
//    println "dirName::${variant.dirName}"
//    def output = "AppConfigTheme"
//
//    File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml")
//    String content = valuesFile.getText('UTF-8')
//    content = content.replaceAll(/\$\{QMUI_PARENT_THEME\}/, output)
//    valuesFile.write(content, 'UTF-8')
//}

dependencies {
    api rootProject.ext.dependencies["appcompat-v7"]
    api rootProject.ext.dependencies["annotations"]
    api rootProject.ext.dependencies["design"]
    api rootProject.ext.dependencies["constraintlayout"]
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
//    lintChecks project(':qm-lintrule')

    //test
    testImplementation 'junit:junit:4.12'
    api 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
    compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
    apply from: rootProject.file('gradle/deploy.gradle')
}