apply plugin: 'com.android.library'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion sdkCompileVersion

    defaultConfig {
        minSdkVersion sdkMinVersion
        targetSdkVersion sdkTargetVersion

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // The schemas directory contains a schema file for each version of the Room database.
        // This is required to enable Room auto migrations.
        // See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration.
        ksp {
            arg("room.schemaLocation", "$projectDir/schemas")
        }
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.toString()
    }

    sourceSets {
        androidTest.java.srcDirs += "src/test-common/java"
        test.java.srcDirs += "src/test-common/java"
        // Room Database Tests
        androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
    }

    packagingOptions {
        resources.excludes.add("META-INF/*")
    }

    namespace "com.owncloud.android.data"
}

dependencies {
    implementation project(":owncloudDomain")

    // Owncloud Android Library
    api project(":owncloudComLibrary")

    // Kotlin
    implementation libs.kotlin.stdlib
    implementation libs.kotlinx.coroutines.core

    // Androidx
    implementation libs.androidx.core.ktx
    implementation libs.androidx.lifecycle.livedata.ktx

    // Room
    implementation libs.androidx.room.ktx
    ksp libs.androidx.room.compiler

    implementation libs.moshi.kotlin
    ksp libs.moshi.kotlin.codegen

    // Timber
    implementation libs.timber

    // Dependencies for unit tests
    testImplementation project(":owncloudTestUtil")
    testImplementation libs.androidx.arch.core.testing
    testImplementation libs.junit4
    testImplementation libs.kotlinx.coroutines.test
    testImplementation libs.mockk

    // Dependencies for instrumented tests
    androidTestImplementation project(":owncloudTestUtil")
    androidTestImplementation libs.androidx.arch.core.testing
    androidTestImplementation libs.androidx.room.testing
    androidTestImplementation libs.androidx.test.espresso.core
    androidTestImplementation libs.androidx.test.ext.junit
    androidTestImplementation libs.androidx.test.runner
    androidTestImplementation libs.kotlinx.coroutines.test
    androidTestImplementation(libs.mockk.android) { exclude module: "objenesis" }

    // Detekt
    detektPlugins libs.detekt.formatting
    detektPlugins libs.detekt.libraries
}
