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

// dynamically retrieve version from package.json
def getPackageVersion() {
    new JsonSlurper().parse(file('../package.json'), 'utf-8').version
}

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

def _buildToolsVersion  = getExtValue('buildToolsVersion', '28.0.3')
def _compileSdkVersion  = getExtValue('compileSdkVersion', 28)
def _targetSdkVersion   = getExtValue('targetSdkVersion', 28)
def _minSdkVersion      = getExtValue('minSdkVersion', 16)

buildscript {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion _compileSdkVersion
    buildToolsVersion _buildToolsVersion

    defaultConfig {
        minSdkVersion _minSdkVersion
        targetSdkVersion _targetSdkVersion
        versionCode 3
        versionName getPackageVersion()
    }
    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"
        name 'React Native (local)'
    }
}

dependencies {
    compileOnly 'com.facebook.react:react-native:+'
}

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

clean.dependsOn customClean
