buildscript {
    ext {
        ANDROID_PLUGIN_VERSION = '8.13.0'
        BUTTERKNIFE_VERSION = '10.2.3'
        KOTLIN_VERSION = '1.9.25'
        // Run "./gradlew dependencyUpdates" to check for updates
        VERSIONS_VERSION = '0.42.0'
        KSP_VERSION = '1.9.25-1.0.20'
    }

    repositories {
        google()
        gradlePluginPortal()
        mavenCentral()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:$ANDROID_PLUGIN_VERSION"
        classpath "com.jakewharton:butterknife-gradle-plugin:$BUTTERKNIFE_VERSION"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
        classpath "com.github.ben-manes:gradle-versions-plugin:$VERSIONS_VERSION"
        classpath 'com.vanniktech:gradle-maven-publish-plugin:0.34.0'
        // Dokka is needed on classpath for vanniktech publish plugin
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.0"
    }
}

plugins {
    id "com.google.devtools.ksp" version "$KSP_VERSION"
}

apply plugin: "com.github.ben-manes.versions"

allprojects {
    repositories {
        google()
        mavenCentral()
    }

    configurations.all {
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
    }
}

subprojects { project ->
    apply from: "$rootDir/blessedDeps.gradle"
}

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

dependencyUpdates.resolutionStrategy {
    componentSelection { rules ->
        rules.all { ComponentSelection selection ->
            boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].any { qualifier ->
                selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
            }
            if (rejected) {
                selection.reject('Release candidate')
            }
        }
    }
}
