// Set engagelabSdkVersion to the SDK release containing the vivo subscription API.
def vivoTemplateSdkVersion = project.findProperty("engagelabSdkVersion") ?: "5.5.3"
group 'cn.engagelab.plugins.push'
version '1.0'

def isNewArchitectureEnabled() {
    return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'

    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
    }
}

apply plugin: 'com.android.library'
if (isNewArchitectureEnabled()) {
    apply plugin: 'com.facebook.react'

    react {
        libraryName = "MTPushEventSpec"
        codegenJavaPackageName = "cn.engagelab.plugins.push"
    }
}

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 27)
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 27)
        versionCode 1
        versionName "1.0"

    }

    sourceSets {
        main.java.srcDirs += isNewArchitectureEnabled()
                ? ['src/newarch/java']
                : ['src/oldarch/java']
    }

}

dependencies {
    //必须 主包
    implementation "com.engagelab:engagelab:${vivoTemplateSdkVersion}"
    //可选，google厂商
    implementation "com.engagelab.plugin:google:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    //可选，honor厂商
    implementation "com.engagelab.plugin:honor:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    implementation "com.engagelab.plugin:honor_th_push:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    //可选，huawei厂商
    implementation "com.engagelab.plugin:huawei:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    //可选，mi厂商
    implementation "com.engagelab.plugin:mi:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    implementation "com.engagelab.plugin:mi_th_push:${vivoTemplateSdkVersion}" // 从SDK5.4.0版本开始需要添加
    //可选，meizu厂商
    implementation "com.engagelab.plugin:meizu:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    implementation "com.engagelab.plugin:meizu_th_push:${vivoTemplateSdkVersion}" // 此处以5.5.3 版本为例。
    //可选，oppo厂商
    implementation "com.engagelab.plugin:oppo:${vivoTemplateSdkVersion}"
    implementation "com.engagelab.plugin:oppo_th_push:${vivoTemplateSdkVersion}"
    //可选，vivo厂商
    implementation "com.engagelab.plugin:vivo:${vivoTemplateSdkVersion}"

    // google push need，不需要 google 通道，则删除
    implementation 'com.google.firebase:firebase-messaging:25.0.1'

    // huawei push need，不需要 huawei 通道，则删除
    implementation 'com.huawei.hms:push:6.11.0.300'
    //oppo以下依赖都需要添加，不需要 oppo 通道，则删除
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'commons-codec:commons-codec:1.6'
    implementation 'androidx.annotation:annotation:1.1.0'

//    implementation fileTree(dir: 'libs', include: ['*.aar'])
//    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.facebook.react:react-native:+'
}
