apply plugin: 'com.android.library'

apply plugin: 'kotlin-android'

def _ext = rootProject.ext

def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 30
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '30.0.2'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 30
def _kotlinVersion = _ext.has('kotlinVersion') ? _ext.kotlinVersion : '1.5.30'
def _junitVersion = _ext.has('junitVersion') ? _ext.junitVersion : '4.13.2'
def _mockitoVersion = _ext.has('mockitoVersion') ? _ext.mockitoVersion : '3.2.0'
def _androidTestRunnerVersion = _ext.has('androidTestRunnerVersion') ? _ext.androidTestRunnerVersion : '1.1.0'

android {
    compileSdkVersion _compileSdkVersion
    buildToolsVersion _buildToolsVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        debug.java.srcDirs += 'src/debug/kotlin'
        test.java.srcDirs += 'src/test/kotlin'
        androidTest.java.srcDirs += 'src/androidTest/kotlin'
    }

    defaultConfig {
        minSdkVersion _minSdkVersion
        targetSdkVersion _targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
        abortOnError false
    }

    testOptions {
      unitTests.returnDefaultValues = true
    }
}

dependencies {
    compileOnly "com.facebook.react:react-native:${_reactNativeVersion}"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${_kotlinVersion}"
    testImplementation "junit:junit:${_junitVersion}"
    testImplementation "org.mockito.kotlin:mockito-kotlin:${_mockitoVersion}"
    testImplementation "org.mockito:mockito-inline:${_mockitoVersion}"
    testImplementation 'com.google.code.gson:gson:2.8.9'
    androidTestImplementation("androidx.test:runner:${_androidTestRunnerVersion}")
    androidTestImplementation("androidx.test:rules:${_androidTestRunnerVersion}")
}
