
apply from: "${rootDir}/gradle/errorprone.gradle"
apply from: "${rootDir}/gradle/checkstyle.gradle"
apply from: "${rootDir}/gradle/spotless.gradle"

android {
    lint {
        checkDependencies true
        lintConfig file("${rootDir}/config/lint.xml")
    }

    packagingOptions {
        resources {
            excludes += [
                    'LICENSE.txt',
                    'META-INF/LICENSE',
                    'META-INF/LICENSE.txt',
                    'META-INF/NOTICE'
            ]
        }
    }

    compileSdkVersion sdkCompileVersion
    buildToolsVersion androidBuildTools

    defaultConfig {
        minSdkVersion sdkMinimumVersion
        targetSdkVersion sdkTargetVersion
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }


    androidResources {
        noCompress ''
    }
}

apply from: "${rootDir}/gradle/android_unit_test.gradle"

afterEvaluate {
    tasks.withType(JavaCompile).configureEach { JavaCompile task ->
        //fail on all warnings
        task.options.compilerArgs << '-Xlint:all'
        //we need to support old devices, so we can trust Java's detection here.
        task.options.compilerArgs << '-Xlint:-deprecation' << '-Xlint:-processing'
        if (task.name.contains('UnitTest')) {
            //for tests, we do not check other stuff too
            task.options.compilerArgs << '-Xlint:-rawtypes' << '-Xlint:-cast' << '-Xlint:-unchecked' << '-Xlint:-classfile'
        }
    }
}