plugins {
    id "com.android.application"
    id "kotlin-android"
//    id "kotlin-kapt"
}
try {
    apply from: 'signing.config.gradle'
} catch (Throwable ignored) {
    println "Warning: No Signing Config found"
    ext.KEY_ALIAS = ""
    ext.KEY_PASSWORD = ""
    ext.STORE_PASSWORD = ""
    ext.KEYSTORE_FILE = ""
}

android {
    compileSdk 35

    defaultConfig {
        applicationId "org.fnives.tiktokdownloader"
        minSdkVersion 23
        targetSdkVersion 35
        versionCode 5
        versionName "1.3.4"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    signingConfigs {
        release {
            keyAlias "$KEY_ALIAS"
            keyPassword "$KEY_PASSWORD"
            storeFile file("$KEYSTORE_FILE")
            storePassword "$STORE_PASSWORD"
        }
    }
    buildTypes {
        debug {
            versionNameSuffix "-dev"
            applicationIdSuffix ".debug"
            debuggable true
            shrinkResources false
            minifyEnabled false
        }
        release {
            signingConfig signingConfigs.release
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
        }
    }
    buildFeatures.buildConfig = true
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = "17"
    }

    testOptions.unitTests {
        includeAndroidResources = true
        all {
            useJUnitPlatform()
            testLogging {
                events 'started', 'passed', 'skipped', 'failed'
                exceptionFormat "full"
                showStandardStreams true
            }
        }
    }
    namespace 'org.fnives.tiktokdownloader'
    lint {
        abortOnError true
        disable "NullSafeMutableLiveData"
    }
}

//tasks.configureEach { task ->
//    if (task.taskIdentity.type.toString() == "class org.jetbrains.kotlin.gradle.tasks.KotlinCompile") {
//        task.kotlinOptions {
//            freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
//        }
//    }
//}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "androidx.core:core-ktx:1.16.0"
    implementation "androidx.appcompat:appcompat:1.7.0"
    implementation "androidx.activity:activity-ktx:1.10.1"
    implementation "androidx.fragment:fragment-ktx:1.8.6"
    implementation "com.google.android.material:material:1.12.0"
    implementation "androidx.constraintlayout:constraintlayout:2.2.1"

    // Coroutines
    def coroutine_version = "1.7.3"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.0"
    implementation "androidx.fragment:fragment-ktx:1.8.6"

    def glide_version = "4.15.1"
    implementation "com.github.bumptech.glide:glide:$glide_version"

    implementation 'com.google.code.gson:gson:2.12.1'

    def okhttp_version = "4.12.0"
    implementation "com.squareup.retrofit2:retrofit:2.9.0"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1'

    def junit_version = "5.8.2"
    testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
    testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
    testImplementation 'com.jraska.livedata:testing-ktx:1.2.0'
    testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
    testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
    testImplementation "commons-io:commons-io:2.13.0"
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_version"
    testImplementation "androidx.arch.core:core-testing:2.2.0"

    androidTestImplementation "androidx.test.ext:junit:1.2.1"
    androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
}