apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def getExtOrDefault(prop, fallback) {
    return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
    
buildscript {
    ext.defaultKotlinVersion = '1.6.10'
    repositories {
        google()
        mavenCentral()
        maven { url 'https://repo.emma.io/emma' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.has('kotlinVersion') ? rootProject.ext.kotlinVersion : defaultKotlinVersion}"
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://repo.emma.io/emma' }
    }
}

android {
    compileSdkVersion getExtOrDefault('compileSdkVersion', 35)
    buildToolsVersion getExtOrDefault('buildToolsVersion', '35.0.0')
    defaultConfig {
        minSdkVersion getExtOrDefault('minSdkVersion', 23)
        targetSdkVersion getExtOrDefault('targetSdkVersion', 35)
        versionCode 1
        versionName "1.0"
    }
    
    namespace "io.emma.reactnative"
    
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getExtOrDefault('kotlinVersion', defaultKotlinVersion)}"
    implementation "com.facebook.react:react-native:${getExtOrDefault('reactNativeVersion', '+')}"
    implementation "io.emma:eMMaSDK:${getExtOrDefault('emmaSdk', '4.15.+')}"
}