buildscript {
    if (project == rootProject) {
        repositories {
            google()
            mavenCentral()
            jcenter()
        }

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

apply plugin: 'com.android.library'

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

def isOwlBuild = project.hasProperty("isOwlBuild")

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 29)
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 29)
        versionCode 1
        versionName "1.0"
    }

     sourceSets {
         main {
             // If this build is triggered by react-native-owl, then include use AndroidManifest.owl.xml
             if (isOwlBuild) {
                 manifest.srcFile 'src/main/AndroidManifest.owl.xml'
             }
         }
     }

    copy {
        from file(isOwlBuild ? "templates/ReactNativeOwlModuleOwl.java": "templates/ReactNativeOwlModule.java")
        into "src/main/java/com/formidable/reactnativeowl"
        rename { "ReactNativeOwlModule.java" }
    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }
    lintOptions {
        disable 'GradleCompatible'
    }
}

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

dependencies {
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
}
