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

buildscript {
    /* In case of submodule usage, do not try to apply own repositories and plugins,
        root project is responsible for that. */
    if (rootProject.buildDir == project.buildDir) {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.0'
        }
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 27)
    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')

    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 27)

        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        abortOnError false
    }
}

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

dependencies {
    implementation "com.android.support:support-v4:${safeExtGet('supportLibVersion', '27.+')}"
    api 'com.facebook.react:react-native:+'
}