// Root-level build.gradle.kts

plugins {
    id("com.google.gms.google-services") apply false
    id("com.android.application") apply false
    id("org.jetbrains.kotlin.android") apply false
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

// Configure build directory
val customBuildDir: Directory = rootProject.layout.buildDirectory
    .dir("../../build")
    .get()

rootProject.layout.buildDirectory.set(customBuildDir)

subprojects {
    val subprojectBuildDir: Directory = customBuildDir.dir(project.name)
    layout.buildDirectory.set(subprojectBuildDir)
}

subprojects {
    afterEvaluate {
        if (project.name != "app") {
            project.evaluationDependsOn(":app")
        }
    }
}

tasks.register<Delete>("clean") {
    delete(rootProject.layout.buildDirectory)
}