import com.moengage.gradle.android.library.plugin.configs.BuildConfigType

ext {
    moengageNativeBOMVersion = "2.2.2"
    moengagePluginBaseBOMVersion = "3.0.1"
    kotlinVersion = "1.9.23"
}

buildscript {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.13.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "com.moengage.android.hybrid.module.config.plugin:com.moengage.android.hybrid.module.config.plugin.gradle.plugin:0.0.4"
    }
}

apply plugin: 'com.moengage.android.hybrid.module.config.plugin'
apply plugin: 'com.facebook.react'

hybridModuleConfig.configurePlugin {
    kotlinOptions {
        enableJvmTarget = false
        compilerArgs = ['-Xjvm-default=all']
    }
    buildFeature {
        buildConfigField(
            BuildConfigType.BOOLEAN,
            "IS_NEW_ARCHITECTURE_ENABLED",
            isNewArchitectureEnabled().toString()
        )
    }
}

android {
    namespace "com.moengage.react.geofence"
    sourceSets {
        main {
            if (isNewArchitectureEnabled()) {
                java.srcDirs += ['src/newarch']
            } else {
                java.srcDirs += ['src/oldarch']
            }
        }
    }
}

dependencies {
    // noinspection GradleDynamicVersion
    compileOnly('com.facebook.react:react-native')
    compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

    implementation(platform("com.moengage:android-bom:$moengageNativeBOMVersion")) 
    compileOnly("com.moengage:moe-android-sdk")
    api("com.moengage:geofence")

    implementation(platform("com.moengage:plugin-base-bom:$moengagePluginBaseBOMVersion"))
    implementation("com.moengage:plugin-base-geofence")
}

def isNewArchitectureEnabled() {
  return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}