apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'de.mannodermaus.android-junit5'

repositories {
    mavenCentral()
    google()
    maven {
        url 'https://jitpack.io'
        content {
            includeModule('com.github.IvanShafran', 'shared-preferences-mock')
            includeModule('com.github.topjohnwu.libsu', 'core')
        }
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.preference:preference-ktx:1.2.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'androidx.work:work-runtime-ktx:2.7.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'

    implementation 'com.google.android.material:material:1.5.0'
    implementation 'com.google.code.gson:gson:2.8.8'
    implementation 'io.github.g00fy2:versioncompare:1.4.1'
    implementation 'com.squareup.okhttp3:okhttp:4.9.3'
    implementation 'ru.gildor.coroutines:kotlin-coroutines-okhttp:1.0'
    implementation "com.github.topjohnwu.libsu:core:4.0.3"

    // Aggregator dependency on JUnit api, engine, and params
    testImplementation "org.junit.jupiter:junit-jupiter:5.8.2"
    testImplementation 'io.mockk:mockk:1.10.5'
    testImplementation 'com.github.IvanShafran:shared-preferences-mock:1.1'
}

android {
    compileSdkVersion 32

    defaultConfig {
        versionCode 98
        versionName "75.4.0" // MAJOR.MINOR.PATCH
        // MAJOR version when you make incompatible API changes,
        // MINOR version when you add functionality in a backwards compatible manner, and
        // PATCH version when you make backwards compatible bug fixes.
        minSdkVersion 21
        targetSdkVersion 32
        vectorDrawables.useSupportLibrary = true
    }

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

    compileOptions {
        encoding = "UTF-8"
        coreLibraryDesugaringEnabled true
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

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

    testOptions {
        // workaround for "Method i in android.util.Log not mocked"
        // without PowerMockito it is impossible to mock Log.
        unitTests.returnDefaultValues = true
        unitTests.includeAndroidResources = true
        unitTests.all {
            testLogging {
                events "passed", "skipped", "failed", "standardOut", "standardError"
                outputs.upToDateWhen { false }
                showStandardStreams = true
            }
        }
    }

    lint {
        abortOnError false
    }
}
