
allprojects {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
        jcenter()
    }

    tasks.withType(JavaCompile) {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
        kotlinOptions {
            jvmTarget = "17"
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    afterEvaluate {
        if (it.hasProperty('android')) {
            if (it.android.namespace == null) {
                def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
                def packageName = manifest.@package.text()
                android.namespace = packageName
            }
            def javaVersion = JavaVersion.VERSION_17
            android {
                def androidApiVersion = 35
                compileSdkVersion androidApiVersion
                defaultConfig {
                    targetSdkVersion androidApiVersion
                }
                compileOptions {
                    sourceCompatibility javaVersion
                    targetCompatibility javaVersion
                }
                tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
                    kotlinOptions {
                        jvmTarget = javaVersion.toString()
                    }
                }
            }
        }
        configurations.all {
            resolutionStrategy {
                force "com.google.crypto.tink:tink:1.13.0"
                exclude group: "com.google.crypto.tink", module: "tink-android"
            }
        }

    }
}
subprojects {
    project.evaluationDependsOn(':app')
}

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