/**
 * Copyright (c) 2018-2020, Matei Bogdan Radu <matei.radu.92@gmail.com>
 *
 * This source code is licensed under the MIT license found in the LICENSE
 * file in the root directory of this source tree.
 */

buildscript {
    ext {
        kotlin_version = "1.3.72"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "27.1.1"
    }

    ext.getRootProjectOrDefaultValueFor = { key ->
        if (rootProject.ext.properties.containsKey(key)) {
            return rootProject.ext.properties.get(key)
        } else {
            return ext.properties.get(key)
        }
    }

    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.diffplug.spotless:spotless-plugin-gradle:3.25.0"
    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven'
apply plugin: 'com.diffplug.gradle.spotless'

spotless {
  kotlin {
    target '**/*.kt'

    ktlint()
  }
}

android {
    compileSdkVersion getRootProjectOrDefaultValueFor("compileSdkVersion")

    defaultConfig {
        minSdkVersion getRootProjectOrDefaultValueFor("minSdkVersion")
        targetSdkVersion getRootProjectOrDefaultValueFor("targetSdkVersion")
    }
    lintOptions {
        abortOnError false
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

repositories {
    maven {
        url "$projectDir/../node_modules/react-native/android"
    }
    mavenCentral()
    google()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'com.facebook.react:react-native:+'
    implementation "com.android.support:appcompat-v7:${getRootProjectOrDefaultValueFor("supportLibVersion")}"
    implementation "com.android.support:support-v4:${getRootProjectOrDefaultValueFor("supportLibVersion")}"
    implementation "com.android.support:customtabs:${getRootProjectOrDefaultValueFor("supportLibVersion")}"
}
