// buildscript {
//     ext.kotlin_version = '1.8.21'

//     ext {
//         compileSdkVersion   = 34
//         targetSdkVersion    = 34
//         appCompatVersion    = "1.1.0"
//     }

//     repositories {
//         google()
//         jcenter()
//     }

//     dependencies {
//         classpath 'com.android.tools.build:gradle:7.1.1'
//         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//     }
// }

allprojects {
    repositories {
        google()
        jcenter()
        def backgroundFetchProject = findProject(':background_fetch')
        if (backgroundFetchProject != null) {
            maven {
                // [required] background_fetch
                url "${backgroundFetchProject.projectDir}/libs"
            }
        }
    }

    // magical code that fixes builds
    subprojects {
        afterEvaluate { project ->
            if (project.hasProperty('android')) {
                project.android {
                    if (namespace == null) {
                        namespace project.group
                    }
                }
            }
        }
    }

}

subprojects {
    afterEvaluate {project ->
        if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
            android {
                compileSdkVersion 36
                buildToolsVersion '36.0.0'
            }
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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