import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

rootProject.buildDir = File("build")

buildscript {
    dependencies {
        classpath(libs.android.gradle)
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21")
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0")
    }
}

plugins {
    id("com.android.application").version("8.0.1").apply(false)
    id("com.android.library").version("8.0.1").apply(false)
    id("org.jetbrains.kotlin.android").version("1.8.21").apply(false)
    id("org.jetbrains.kotlin.kapt").version("1.8.21").apply(false)
    id("com.google.dagger.hilt.android").version("2.44.2").apply(false)
    id("org.jetbrains.kotlin.jvm") version "1.8.20" apply false
}

subprojects {
    project.buildDir = File("${rootProject.buildDir}/${project.name}")

    tasks.withType<KotlinCompile>() {
        kotlinOptions {
            freeCompilerArgs = listOf("-Xjsr305=strict")
            jvmTarget = "11"
        }
    }

    tasks.withType<KaptGenerateStubs> {
        compilerOptions {
            jvmTarget.set(JvmTarget.JVM_11)
        }
    }
}

tasks.register("clean", Delete::class) {
    delete(rootProject.buildDir)
}