// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

plugins {
    id 'firebase-library'
    id 'firebase-vendor'
}

firebaseLibrary {
    libraryGroup = "appdistribution"
    publishJavadoc = false
    previewMode = "beta"
    releaseNotes {
        name.set("{{appdistro}}")
        versionName.set("app-distro")
    }
}

android {
    namespace "com.google.firebase.appdistribution.impl"
    compileSdkVersion project.compileSdkVersion

    defaultConfig {
        minSdkVersion project.minSdkVersion
        targetSdkVersion project.targetSdkVersion
        multiDexEnabled true
        versionName version
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }
}

thirdPartyLicenses {
    add 'Apache-2.0', "${rootDir}/third_party/licenses/apache-2.0.txt"
    add 'Dagger', "${rootDir}/third_party/licenses/dagger.txt"
}

dependencies {
    vendor (libs.dagger.dagger) {
        exclude group: "javax.inject", module: "javax.inject"
    }

    api(project(":firebase-appdistribution-api")) {
        exclude group: 'com.google.firebase', module: 'firebase-common'
        exclude group: 'com.google.firebase', module: 'firebase-components'
    }
    api libs.firebase.common
    api libs.firebase.components
    api('com.google.firebase:firebase-installations-interop:17.1.0') {
        exclude group: 'com.google.firebase', module: 'firebase-common'
        exclude group: 'com.google.firebase', module: 'firebase-components'
    }

    implementation libs.androidx.appcompat
    implementation libs.androidx.browser
    implementation libs.androidx.constraintlayout
    implementation libs.playservices.tasks
    implementation libs.javax.inject
    implementation libs.kotlin.stdlib.jdk8

    compileOnly libs.autovalue.annotations

    runtimeOnly('com.google.firebase:firebase-installations:18.0.0') {
        exclude group: 'com.google.firebase', module: 'firebase-common'
        exclude group: 'com.google.firebase', module: 'firebase-common-ktx'
        exclude group: 'com.google.firebase', module: 'firebase-components'
    }

    annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
    annotationProcessor libs.dagger.compiler

    testImplementation project(path: ':firebase-appdistribution')
    testImplementation(project(":integ-testing")){
        exclude group: 'com.google.firebase', module: 'firebase-common'
        exclude group: 'com.google.firebase', module: 'firebase-components'
    }
    testImplementation libs.androidx.test.core
    testImplementation libs.truth
    testImplementation libs.junit
    testImplementation libs.mockito.core
    testImplementation libs.robolectric

    androidTestImplementation(project(":integ-testing")){
        exclude group: 'com.google.firebase', module: 'firebase-common'
        exclude group: 'com.google.firebase', module: 'firebase-components'
    }
    androidTestImplementation libs.androidx.annotation
    androidTestImplementation libs.androidx.test.runner
    androidTestImplementation libs.androidx.test.junit
    androidTestImplementation libs.truth
    androidTestImplementation libs.junit
    androidTestImplementation libs.mockito.core
}
