apply plugin: 'com.android.library'
apply from: 'gradle-maven-push.gradle'

def DEFAULT_COMPILE_SDK_VERSION               = 27
def DEFAULT_BUILD_TOOLS_VERSION               = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION                = 27
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION      = "16.0.1"
def DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION = "16.0.0"
def DEFAULT_ANDROID_MAPS_UTILS_VERSION        = "0.5+"

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

android {
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)

  defaultConfig {
    minSdkVersion 16
    targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
  }

  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'
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
  }
}

dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION
  def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION))
  def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION)

  compileOnly "com.facebook.react:react-native:+"
  implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion"
  implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"
  implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
}
