import groovy.json.JsonSlurper

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

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

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

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion _compileSdkVersion
    buildToolsVersion _buildToolsVersion

    defaultConfig {
        minSdkVersion _minSdkVersion
        targetSdkVersion _targetSdkVersion
        versionCode 4
        versionName getPackageVersion()
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenLocal()
    google()
    jcenter()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}

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

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

clean.dependsOn customClean
