plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
}

android {
    compileSdk = Version.compileSdk

    defaultConfig {
        minSdk = Version.minSdk

        consumerProguardFiles("consumer-rules.pro")
    }

    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }

    compileOptions {

        targetCompatibility(JavaVersion.VERSION_17)
        sourceCompatibility(JavaVersion.VERSION_17)
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
        freeCompilerArgs = freeCompilerArgs + listOf("-module-name", "loading_state_view_ktx")
    }
    namespace = "com.dylanc.loadingstateview.ext"

    configurations.all {
        resolutionStrategy {
            eachDependency {
                when (requested.group) {
                    "androidx.lifecycle" -> {
                        useVersion("2.6.1")
                    }

                    "androidx.appcompat" -> {
                        if (requested.name == "appcompat") {
                            useVersion("1.4.2")
                        }
                    }
                }
            }
        }
    }
}

dependencies {
    compileOnly(project(mapOf("path" to ":loadingstateview")))
    compileOnly(Deps.appcompat)
}