buildscript {

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'
    }
}

repositories {
    maven {
        url "${projectDir}/../local-maven-repo"
    }
    mavenCentral()
    maven {
        url 'https://s01.oss.sonatype.org/content/repositories/releases'
    }
}

apply plugin: "io.spring.dependency-management"
dependencyManagement {
    imports {
    }
}

apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'

kotlin {
    jvmToolchain(11)
}

// Load API keys from local.properties for local development
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withInputStream { localProperties.load(it) }
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    compileSdkVersion 34
    defaultConfig {
        applicationId "com.aegir.demo"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 2
        versionName "2.1.11"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        // Try environment variables first (for CI/CD), then local.properties, then placeholder
        resValue "string", "maptiler_api_key", System.getenv('MAPTILER_API_KEY') ?: localProperties.getProperty('MAPTILER_API_KEY', '{YOUR_MAP_TILER_KEY_HERE}')
        resValue "string", "google_maps_key", System.getenv('GOOGLE_MAPS_API_KEY') ?: localProperties.getProperty('GOOGLE_MAPS_API_KEY', '{YOUR_GOOGLE_MAPS_KEY_HERE}')
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/DEPENDENCIES', 'META-INF/NOTICE', 'META-INF/LICENSE']
        }
    }
    namespace 'com.aegir.demo'
    buildFeatures {
        viewBinding true
        buildConfig true
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.4.8'
    }
}

dependencies {
    implementation 'com.aegirmaps:vmsdk-core:2.1.11'
    implementation 'com.aegirmaps:vmsdk-legacy:2.1.11'
    implementation 'org.maplibre.gl:android-sdk:11.6.1'
    implementation 'androidx.preference:preference-ktx:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    implementation "com.google.android.gms:play-services-location:21.0.1"
    implementation "com.google.android.gms:play-services-maps:18.1.0"
    implementation 'androidx.test.ext:junit:1.1.5'

    def composeBom = platform('androidx.compose:compose-bom:2023.06.01')
    implementation composeBom
    androidTestImplementation composeBom
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.compose.material:material-icons-core'
    implementation 'androidx.navigation:navigation-compose:2.6.0'
    debugImplementation 'androidx.compose.ui:ui-tooling'

    testImplementation 'junit:junit:4.12'
    testImplementation 'org.assertj:assertj-core:1.7.1'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support'
    })
}

configurations {
    all*.exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
}
