plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlinx-serialization'

    // ksp for room database
    id 'com.google.devtools.ksp'
}

apply plugin: 'com.google.protobuf'
apply plugin: 'kotlin-android'

android {
    namespace 'com.birdthedeveloper.prometheus.android.exporter'
    compileSdk 33

    defaultConfig {
        applicationId "com.birdthedeveloper.prometheus.android.exporter"
        minSdk 26
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.4.7'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    kotlinOptions {
        jvmTarget = "17"
    }
}

protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.11.0' }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java { option 'lite' }
            }
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.10.1'

    // ktor
    implementation "io.ktor:ktor-client-android:2.3.0"
    implementation "io.ktor:ktor-client-cio:2.3.0"

    // custom - tests
    androidTestImplementation 'androidx.test:runner:1.5.2'
    androidTestUtil 'androidx.test:orchestrator:1.4.2'

    //  - work manager
    implementation 'androidx.work:work-multiprocess:2.8.1'

    def core_version = "1.10.1"

    //  - prometheus client java library
    implementation 'io.prometheus:simpleclient:0.16.0'
    implementation 'io.prometheus:simpleclient_common:0.16.0'

    //  - kotlin coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.0-RC"

    //  - ktor web client
    implementation("io.ktor:ktor-client-core:2.3.0")
    implementation("io.ktor:ktor-client-cio:2.3.0")

    //  - ktor web server
    implementation "io.ktor:ktor-server-cio:2.3.0"
    implementation "io.ktor:ktor-server-core:2.3.0"
    implementation "io.ktor:ktor-server-status-pages:2.3.0"

    //  - view model for Jetpack Compose
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
    implementation "androidx.core:core-ktx:$core_version"

    //  - navigation for Jetpack Compose
    def nav_version = "2.5.3"
    implementation("androidx.navigation:navigation-compose:$nav_version")

    //  - work manager
    implementation 'androidx.work:work-runtime-ktx:2.7.1'

    //  - yaml configuration parsing
    implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.1")
    implementation("com.charleskorn.kaml:kaml:0.54.0")
    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1'

    //  - protocol buffers
    implementation 'com.google.protobuf:protobuf-javalite:3.20.1'
    implementation 'com.google.protobuf:protobuf-kotlin-lite:3.20.1'

    // snappy compression for remote write
    implementation 'org.iq80.snappy:snappy:0.4'


    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
    implementation 'androidx.activity:activity-compose:1.7.1'
    implementation "androidx.compose.ui:ui:$compose_ui_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
    implementation 'androidx.compose.material:material:1.4.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}