// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

def _playServicesPlacesVersion = safeExtGet('playServicesPlacesVersion', '16.0.0')
def _googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', _playServicesPlacesVersion)
def _buildToolsVersion  = safeExtGet('buildToolsVersion', '28.0.3')
def _minSdkVersion      = safeExtGet('minSdkVersion', 21)
def _compileSdkVersion  = safeExtGet('compileSdkVersion', 28)
def _targetSdkVersion   = safeExtGet('targetSdkVersion', 28)
def _supportLibVersion  = safeExtGet('supportLibVersion', '28.0.0')

buildscript {
    repositories {
        mavenLocal()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion _compileSdkVersion
    buildToolsVersion _buildToolsVersion

    defaultConfig {
        minSdkVersion _minSdkVersion
        targetSdkVersion _targetSdkVersion
        versionCode 2
        versionName '0.2.0'
    }
    lintOptions {
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    mavenLocal()
    google()
    jcenter()
    maven { url "$rootDir/../node_modules/react-native/android" }
}

/*
    Should I use the "api" keyword for places?
    implementation vs api: https://stackoverflow.com/questions/44413952
*/
dependencies {
    compileOnly 'com.facebook.react:react-native:+'
    implementation "com.google.android.gms:play-services-places:${_playServicesPlacesVersion}"
    implementation "com.google.android.gms:play-services-maps:${_googlePlayServicesMapsVersion}"
    implementation "com.android.support:support-v4:${_supportLibVersion}"
}

task customClean(type: Delete) {
    delete rootProject.buildDir
}

clean.dependsOn customClean
