apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION             = 28
def DEFAULT_TARGET_SDK_VERSION              = 28
def DEFAULT_SUPPORT_LIB_VERSION             = "28.0.0"
def DEFAULT_MIN_SDK_VERSION                 = 16

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


android {
    compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
        targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
        resValue "string", "places_api_key", (System.env.RNGP_ANDROID_API_KEY ? "$System.env.RNGP_ANDROID_API_KEY" : (rootProject.findProperty("RNGP_ANDROID_API_KEY") ?: "INSERT_KEY_HERE"))
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    lintOptions {
        disable 'InvalidPackage'
    }
}

dependencies {
    def supportLibVersion = safeExtGet('supportLibVersion', DEFAULT_SUPPORT_LIB_VERSION)

    implementation "com.facebook.react:react-native:+"
    implementation "com.google.android.libraries.places:places:1.1.0"
    implementation "com.android.support:appcompat-v7:${supportLibVersion}"
    implementation "com.android.support:support-v4:${supportLibVersion}"
    implementation "com.google.code.findbugs:jsr305:3.0.2"
}
