buildscript {
    if (project == rootProject) {
        repositories {
            google()
            mavenCentral()
            //jcenter()
            def REPOSITORY_URL = 'https://maven.aliyun.com/nexus/content/groups/public/'
            all { ArtifactRepository repo ->
                if(repo instanceof MavenArtifactRepository){
                    def url = repo.url.toString()
                    if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                        project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                        remove repo
                    }
                }
            }
            maven {
                url REPOSITORY_URL
                allowInsecureProtocol = true
            }
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.3'
        }
    }
}

apply plugin: 'com.android.library'

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

android {
    compileSdkVersion safeExtGet('AwesomeModule_compileSdkVersion', 29)
    defaultConfig {
        minSdkVersion safeExtGet('AwesomeModule_minSdkVersion', 16)
        targetSdkVersion safeExtGet('AwesomeModule_targetSdkVersion', 29)
        versionCode 1
        versionName "1.0"

    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }
    lintOptions {
        disable 'GradleCompatible'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url("$rootDir/../node_modules/react-native/android")
    }
    google()
    mavenCentral()
    //jcenter()
    def REPOSITORY_URL = 'https://maven.aliyun.com/nexus/content/groups/public/'
    all { ArtifactRepository repo ->
        if(repo instanceof MavenArtifactRepository){
            def url = repo.url.toString()
            if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                remove repo
            }
        }
    }
    maven {
        url REPOSITORY_URL
        allowInsecureProtocol = true
    }
}

dependencies {
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.yandex.android:mobmetricalib:5.0.0'
    implementation "com.yandex.android:mobmetricapushlib:2.2.0"
    implementation "com.android.support:support-compat:28.0.0"
    implementation 'com.android.installreferrer:installreferrer:1.1.2'
    implementation "com.google.firebase:firebase-messaging:22.0.0"
    implementation "com.google.android.gms:play-services-base:17.5.0"
}
