import com.github.spotbugs.snom.SpotBugsTask

apply plugin: 'com.android.application'
apply plugin: 'com.github.spotbugs'

spotbugs {
    ignoreFailures = false
    effort = 'max'
    excludeFilter = file("./config/spotbugs/exclude.xml")
    reportsDir = file("$buildDir/reports/spotbugs/")
}

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "me.hackerchick.catima"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 96
        versionName "2.12.0"

        vectorDrawables.useSupportLibrary true
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "app_name", "Catima"
        }
        debug {
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "Catima Debug"
        }
    }

    bundle {
        language {
            enableSplit = false
        }
    }

    compileOptions {
        encoding "UTF-8"

        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true

        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    lintOptions {
        disable "GoogleAppIndexingWarning", "ButtonStyle", "AlwaysShowAction",
                "MissingTranslation", "MissingPrefix"
    }

    sourceSets {
        test {
            resources.srcDirs += ['src/test/res']
        }
    }

    // Starting with Android Studio 3 Robolectric is unable to find resources.
    // The following allows it to find the resources.
    testOptions {
        unitTests {
            all {
                testLogging {
                    events 'started', 'passed', 'skipped', 'failed'
                }
            }
            includeAndroidResources true
        }
    }
}

dependencies {
// AndroidX
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
    implementation 'androidx.exifinterface:exifinterface:1.3.3'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.github.yalantis:ucrop:2.2.7'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

// Splash Screen
    implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'

// Third-party
    implementation 'com.journeyapps:zxing-android-embedded:4.3.0@aar'
    implementation 'com.google.zxing:core:3.4.1'
    implementation 'org.apache.commons:commons-csv:1.9.0'
    implementation 'com.jaredrummler:colorpicker:1.1.0'
    implementation 'com.github.invissvenska:NumberPickerPreference:1.0.4'
    implementation 'net.lingala.zip4j:zip4j:2.9.1'

// SpotBugs
    implementation 'io.wcm.tooling.spotbugs:io.wcm.tooling.spotbugs.annotations:1.0.0'

// Testing
    testImplementation 'androidx.test:core:1.4.0'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.robolectric:robolectric:4.7.3'
}

tasks.withType(SpotBugsTask) {

    description 'Run spotbugs'
    group 'verification'

    //classes = fileTree('build/intermediates/javac/debug/compileDebugJavaWithJavac/classes')
    //source = fileTree('src/main/java')
    //classpath = files()

    reports {
        xml.enabled = false
        html.enabled = true
    }
}
