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 {
    repositories {
        google()
        mavenCentral()
    }

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

plugins {
    alias(libs.plugins.ksp).apply(false)
    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("com.google.protobuf").version("0.9.3").apply(false)
    id("org.jetbrains.kotlin.plugin.serialization").version("1.8.21").apply(false)
}

subprojects {
    project.buildDir = File("${rootProject.buildDir}/${project.path.replace(":", "/")}")

    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)
}