buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:8.8.1'
        classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.2.0'
        classpath 'com.puppycrawl.tools:checkstyle:10.23.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply plugin: 'idea'


dependencies {

    // Android stuff
    implementation 'androidx.appcompat:appcompat-resources:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.core:core-ktx:1.15.0'
    implementation 'androidx.drawerlayout:drawerlayout:1.2.0'
    implementation 'androidx.lifecycle:lifecycle-process:2.8.7'
    implementation 'androidx.preference:preference-ktx:1.2.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.material:material:1.12.0'

    implementation 'com.google.guava:guava:33.4.8-jre'
    implementation 'javax.inject:javax.inject:1'
    implementation 'joda-time:joda-time:2.13.1'
    implementation 'org.apache.commons:commons-csv:1.12.0'
    implementation 'org.apache.commons:commons-text:1.13.1'

    compileOnly 'javax.annotation:jsr250-api:1.0'

    kapt 'com.google.dagger:dagger-compiler:2.53'
    kapt 'com.google.dagger:dagger-android-processor:2.53'
    api 'com.google.dagger:dagger-android-support:2.53'
    api 'com.google.dagger:dagger-android:2.53'
    api 'com.google.dagger:dagger:2.53'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:5.17.0'

    // For some reason without this build fails with duplicate classes exception.
    implementation(platform('org.jetbrains.kotlin:kotlin-bom:2.1.21'))
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions.incremental = false

    buildFeatures.buildConfig = true

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.compileSdkVersion

        namespace 'me.tsukanov.counter'
        applicationId 'me.tsukanov.counter'
        versionCode rootProject.ext.appVersion
        versionName "${rootProject.ext.appVersion}"

        testInstrumentationRunner "android.test.InstrumentationTestRunner"

        multiDexEnabled true
    }

    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            renderscriptDebuggable false
            pseudoLocalesEnabled false

            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    testOptions {
        unitTests {
            returnDefaultValues = true
            includeAndroidResources = true
        }
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

}

idea {
    module {
        downloadJavadoc = true
        downloadSources = true
    }
}

apply plugin: 'com.github.spotbugs'
spotbugs {
    ignoreFailures = true
}

apply plugin: 'checkstyle'
checkstyle {
    configFile rootProject.file('checkstyle.xml')
    ignoreFailures false
    maxWarnings = 0
    showViolations true
}

tasks.register('checkstyle', Checkstyle) {
    source 'src/main/java'
    source 'src/test/java'
    include '**/*.java'
    classpath = files()
}

preBuild.dependsOn('checkstyle')
assemble.dependsOn('lint')
check.dependsOn('checkstyle')
