apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.devtools.ksp'

android {
    namespace "com.airbnb.paris.sample"
    compileSdkVersion rootProject.COMPILE_SDK_VERSION

    defaultConfig {
        applicationId "com.airbnb.paris.sample"
        minSdkVersion rootProject.SAMPLE_MIN_SDK_VERSION
        targetSdkVersion rootProject.TARGET_SDK_VERSION
    }

    buildFeatures {
        buildConfig = true
    }

    compileOptions {
        sourceCompatibility rootProject.JAVA_SOURCE_VERSION
        targetCompatibility rootProject.JAVA_TARGET_VERSION
    }

    kotlinOptions {
        jvmTarget = '11'
    }
}

dependencies {
    implementation project(':paris')

    implementation deps.appcompat
    implementation deps.coroutines
    implementation deps.constraintLayout

    ksp project(':paris-processor')
}

kotlin {
    sourceSets.main {
        kotlin.srcDir("build/generated/ksp/main/kotlin")
    }
    sourceSets.test {
        kotlin.srcDir("build/generated/ksp/test/kotlin")
    }
}

// Make KSP wait for resource generation so R classes are available
afterEvaluate {
    tasks.matching { it.name.startsWith("ksp") && it.name.endsWith("Kotlin") }.configureEach {
        def variant = it.name.replace("ksp", "").replace("Kotlin", "")
        def processResourcesTask = tasks.findByName("process${variant}Resources")
        if (processResourcesTask) {
            it.dependsOn(processResourcesTask)
        }
    }
}
