// Copyright 2020 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 'com.android.application'
    id 'kotlin-android'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.appdistribution'
    id 'copy-google-services'
}

android {
    namespace "com.google.firebase.appdistribution.testapp"
    compileSdk 33

    defaultConfig {
        applicationId "com.googletest.firebase.appdistribution.testapp"
        minSdk 23
        targetSdk 34
        versionName "3.3"
        versionCode 8

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildFeatures {
        buildConfig = true
    }

    buildTypes {
        release {
            // This is so we can build the "release" variant for the "test-app" (and the SDK) without
            // needing to have the app signed.
            initWith debug
        }
    }

    flavorDimensions.add("environment")

    productFlavors {
        prod {
            dimension "environment"
            versionNameSuffix "-prod"
        }

        beta {
            dimension "environment"
            versionNameSuffix "-beta"

            firebaseAppDistribution {
                releaseNotes = "Beta variant of Android SDK test app"
                // testers = "your email here"
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_1_8 } }

dependencies {
    // TODO(rachelprince): Add flag to build with public version of SDK
    println("Building with HEAD version ':firebase-appdistribution' of SDK")

    version ':firebase-appdistribution'

    // In this test project we also need to explicitly declare these dependencies
    implementation project(':firebase-appdistribution-api')
    // All variants use the API
    implementation "androidx.activity:activity-ktx:1.6.0"
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "androidx.core:core:1.9.0"
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation "androidx.fragment:fragment-ktx:1.5.3"
    implementation "com.google.android.gms:play-services-tasks:18.0.2"
    implementation 'com.google.android.material:material:1.6.1'
    // Shake detection
    implementation 'com.squareup:seismic:1.0.3'
    // Other dependencies
    implementation libs.kotlin.stdlib

    // Beta flavor uses the full implementation
    betaImplementation project(':firebase-appdistribution')

    testImplementation libs.junit
}
