// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        // https://developer.android.com/jetpack/androidx/releases/compose
        compose_version = "1.1.1"

        // https://github.com/detekt/detekt/releases
        detektVersion = "1.23.8"

        // https://developer.android.com/jetpack/androidx/releases/hilt
        hiltVersion = libs.versions.hilt.get()

        kotlinVersion = "1.9.21"

        // https://github.com/ben-manes/gradle-versions-plugin
        versionsPluginVersion = "0.51.0"

        // https://github.com/Kotlin/kotlinx-kover/releases
        koverVersion = "0.6.1"

        ext.jacocoAndroidVersion = "0.2"

        ext.coverallsVersion = "2.12.2"
    }
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:8.7.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
        classpath "com.github.ben-manes:gradle-versions-plugin:$versionsPluginVersion"
        classpath "org.jetbrains.kotlinx:kover:$koverVersion"
        classpath "gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:$coverallsVersion"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "com.mxalbert.gradle.jacoco-android" version "0.2.1" apply false
    id "org.jmailen.kotlinter" version "4.3.0" apply false
    alias(libs.plugins.ksp).apply(false)
}

apply from: "buildscripts/git-hooks.gradle"
apply from: "buildscripts/versions.gradle"

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
        }
    }
}

subprojects {
    apply plugin: "org.jmailen.kotlinter"
    apply from: "../buildscripts/detekt.gradle"
    apply from: "../buildscripts/versionsplugin.gradle"
    apply from: "../buildscripts/kover.gradle"

    afterEvaluate {
        gradle.projectsEvaluated {
            tasks.withType(JavaCompile.class).tap {
                configureEach {
                    sourceCompatibility = "17"
                    targetCompatibility = "17"
                }
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

afterEvaluate {
    tasks['clean'].dependsOn installGitHooks
}