import groovy.json.JsonSlurper

def computeVersionName() {
    // dynamically retrieve version from package.json
    def slurper = new JsonSlurper()
    def json = slurper.parse(file('../package.json'), "utf-8")
    return json.version
}
def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion  safeExtGet('compileSdkVersion', 26)
    buildToolsVersion  safeExtGet('buildToolsVersion', "26.0.2")

    defaultConfig {
        minSdkVersion  safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 22)
        versionCode 1
        // get version name from package.json version
        versionName computeVersionName()

    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.facebook.react:react-native:+'
    implementation group: 'commons-io', name: 'commons-io', version: '2.5'
}
