/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion config.compileSdkVersion

    defaultConfig {
        minSdkVersion config.minSdkVersion
        targetSdkVersion config.targetSdkVersion
    }

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

    sourceSets {
        test {
            resources {
                // We want to access the assets from unit tests. With this configuration we can just
                // read the files directly and do not need to rely on Robolectric.
                srcDir "${projectDir}/src/main/assets/"
            }
        }
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions.freeCompilerArgs += [
        "-Xopt-in=kotlinx.coroutines.FlowPreview",
        "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
    ]
}

dependencies {
    implementation project(":feature-tabs")
    implementation project(':browser-state')
    implementation project(':concept-engine')
    implementation project(':service-location')
    implementation project(':support-utils')
    implementation project(':support-ktx')

    implementation Dependencies.kotlin_stdlib

    testImplementation project(':support-test')
    testImplementation project(':support-test-fakes')
    testImplementation project(':support-test-libstate')
    testImplementation Dependencies.androidx_test_core
    testImplementation Dependencies.androidx_test_junit
    testImplementation Dependencies.testing_robolectric
    testImplementation Dependencies.testing_mockito
    testImplementation Dependencies.testing_coroutines
}

tasks.register("updateAdsExtensionVersion", org.gradle.api.tasks.Copy) { task ->
    updateExtensionVersion(task, 'src/main/assets/extensions/ads')
}

tasks.register("updateCookiesExtensionVersion", org.gradle.api.tasks.Copy) { task ->
    updateExtensionVersion(task, 'src/main/assets/extensions/search')
}

preBuild.dependsOn "updateAdsExtensionVersion"
preBuild.dependsOn "updateCookiesExtensionVersion"

apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)
