/*
 * SPDX-FileCopyrightText: 2021 The Calyx Institute
 * SPDX-License-Identifier: Apache-2.0
 */

plugins {
    id 'com.android.library'
    id 'com.google.protobuf'
    id 'org.jetbrains.kotlin.android'
    id 'org.jetbrains.kotlin.kapt'
    id 'org.jetbrains.dokka'
    id 'org.jlleitschuh.gradle.ktlint'
}

android {
    namespace 'org.calyxos.backup.storage'
    compileSdk rootProject.ext.compileSdk

    defaultConfig {
        minSdk rootProject.ext.minSdk
        targetSdk rootProject.ext.targetSdk

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments disableAnalytics: 'true'

        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        all {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
        languageVersion = "1.7"
        freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
        freeCompilerArgs += '-Xexplicit-api=strict'
    }
    protobuf {
        protoc {
            if ("aarch64" == System.getProperty("os.arch")) {
                // mac m1
                artifact = "com.google.protobuf:protoc:$protobuf_version:osx-x86_64"
            } else {
                // other
                artifact = "com.google.protobuf:protoc:$protobuf_version"
            }
        }
        generateProtoTasks {
            all().each { task ->
                task.builtins {
                    java {
                        option "lite"
                    }
                }
            }
        }
    }
    lint {
        disable "DialogFragmentCallbacksDetector",
                "InvalidFragmentVersionForActivityResult",
                "CheckedExceptions"
    }
}

kotlin {
    explicitApi = 'strict'
}

dependencies {
    implementation rootProject.ext.kotlin_libs.std

    implementation rootProject.ext.std_libs.androidx_core
    // A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
    implementation rootProject.ext.std_libs.androidx_fragment
    implementation rootProject.ext.std_libs.androidx_activity
    implementation rootProject.ext.std_libs.androidx_lifecycle_viewmodel_ktx
    implementation rootProject.ext.std_libs.androidx_lifecycle_livedata_ktx
    implementation rootProject.ext.std_libs.androidx_constraintlayout
    implementation rootProject.ext.std_libs.androidx_documentfile
    implementation rootProject.ext.std_libs.com_google_android_material

    implementation rootProject.ext.storage_libs.androidx_room_runtime
    implementation rootProject.ext.storage_libs.com_google_protobuf_javalite
    implementation rootProject.ext.storage_libs.com_google_crypto_tink_android
    kapt('androidx.room:room-compiler') {
        version { strictly "$room_version" }
    }

    lintChecks rootProject.ext.lint_libs.exceptions

    testImplementation "junit:junit:$junit4_version"
    testImplementation "io.mockk:mockk:$mockk_version"
    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"

    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
}

apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"
