plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'shot'
    id 'org.jetbrains.kotlin.plugin.compose'
}

if (project.hasProperty('useKsp')) {
    apply plugin: 'com.google.devtools.ksp'
    kotlin {
        sourceSets.configureEach {
            kotlin.srcDirs += "build/generated/ksp/${it.name}/kotlin"
        }
    }
} else {
    apply plugin: 'kotlin-kapt'
    kapt {
        correctErrorTypes = true
    }
}

android {
    namespace "com.airbnb.android.showkasesample"

    defaultConfig {
        applicationId "com.airbnb.android.showkasesample"
        minSdkVersion 21
        compileSdk 36
        targetSdkVersion 35
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        compose true
    }
    // Added to avoid this error -
    // Execution failed for task ':app:mergeDebugAndroidTestJavaResource'.
    // > A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
    // > 2 files found with path 'META-INF/AL2.0' from inputs:
    packagingOptions {
        exclude 'META-INF/AL2.0'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/gradle/incremental.annotation.processors'
    }
}
if (project.hasProperty("useKsp")) {
    ksp {
        arg("skipPrivatePreviews", "true")
    }
} else {
    kapt {
        arguments {
            arg("skipPrivatePreviews", "true")
        }
    }
}

kotlin {
    jvmToolchain(17)
}

dependencies {
    // Showkase dependencies
    // TODO(vinaygaba): Using debugImplementation was causing kapt related NonExistentClass errors.
    //  Figure out a way to enable using debugImplementation
    implementation project(':showkase')
    implementation project(':sample-submodule')
    implementation project(':sample-submodule-2')
    if (project.hasProperty('useKsp')) {
        ksp project(':showkase-processor')
        kspAndroidTest project(':showkase-processor')
    } else {
        kapt project(':showkase-processor')
        kaptAndroidTest project(':showkase-processor')
    }

    // Support Libraries
    implementation deps.support.appCompat
    implementation deps.support.ktx
    implementation deps.support.lifecycleComposeViewModel
    implementation deps.support.lifecycleComposeRuntime

    // Compose
    implementation deps.compose.activityCompose
    implementation deps.compose.composeRuntime
    implementation deps.compose.constraintLayout
    implementation deps.compose.core
    implementation deps.compose.foundation
    implementation deps.compose.tooling
    implementation deps.compose.layout
    implementation deps.compose.material
    implementation deps.compose.savedInstanceState
    implementation deps.compose.uiLiveData
    androidTestImplementation deps.compose.uiTest

    // Image loading
    implementation deps.imageLoading.picasso

    // Testing
    testImplementation deps.test.junit
    androidTestImplementation deps.test.junitImplementation
    androidTestImplementation project(':showkase-screenshot-testing-shot')
}
